|
1 | | -const fs = require('fs') |
| 1 | +const fs = require('fs') |
| 2 | +const path = require('path') |
| 3 | +const pkg = require(path.resolve(__dirname, '../package.json')) |
| 4 | +const year = new Date().getFullYear() |
2 | 5 |
|
3 | | -fs.readFile('package.json', (err, data) => { |
4 | | - if (err) { |
5 | | - throw err |
6 | | - } |
| 6 | +const pathBoostrap = path.resolve(__dirname, '../dist/js/bootstrap.js') |
| 7 | +const pathBootstrapBundle = path.resolve(__dirname, '../dist/js/bootstrap.bundle.js') |
| 8 | +const contentFile = fs.readFileSync(pathBoostrap, { encoding: 'UTF8' }) |
| 9 | +const contentBundleFile = fs.readFileSync(pathBootstrapBundle, { encoding: 'UTF8' }) |
7 | 10 |
|
8 | | - const pkg = JSON.parse(data) |
9 | | - const year = new Date().getFullYear() |
10 | | - |
11 | | - const stampTop = |
| 11 | +const stamp = |
12 | 12 | `/*! |
13 | 13 | * Bootstrap v${pkg.version} (${pkg.homepage}) |
14 | 14 | * Copyright 2011-${year} ${pkg.author} |
15 | 15 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
16 | 16 | */ |
17 | | -
|
18 | | -if (typeof jQuery === 'undefined') { |
19 | | - throw new Error('Bootstrap\\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\\'s JavaScript.') |
20 | | -} |
21 | | -
|
22 | | -(function ($) { |
23 | | - var version = $.fn.jquery.split(' ')[0].split('.') |
24 | | - if ((version[0] < 3) || (version[0] >= 4)) { |
25 | | - throw new Error('Bootstrap\\'s JavaScript requires at least jQuery v3.0.0 but less than v4.0.0') |
26 | | - } |
27 | | -})(jQuery); |
28 | | -
|
29 | | -(function () { |
30 | 17 | ` |
31 | | - const stampEnd = ` |
32 | | -})();` |
33 | | - |
34 | | - process.stdout.write(stampTop) |
35 | | - |
36 | | - process.stdin.on('end', () => { |
37 | | - process.stdout.write(stampEnd) |
38 | | - }) |
39 | | - |
40 | | - process.stdin.pipe(process.stdout) |
41 | | -}) |
| 18 | +fs.writeFileSync(pathBoostrap, `${stamp}${contentFile}`, { encoding: 'UTF8' }) |
| 19 | +fs.writeFileSync(pathBootstrapBundle, `${stamp}${contentBundleFile}`, { encoding: 'UTF8' }) |
0 commit comments