|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +let pkg = require('./compat/package.json'); |
| 4 | +let fs = require('fs-extra'); |
| 5 | +let mkdirp = require('mkdirp'); |
| 6 | +let path = require('path'); |
| 7 | +let klawSync = require('klaw-sync'); |
| 8 | +let licenseTool = require('./tools/add-license-to-file'); |
| 9 | +let addLicenseToFile = licenseTool.addLicenseToFile; |
| 10 | +let addLicenseTextToFile = licenseTool.addLicenseTextToFile; |
| 11 | + |
| 12 | +const ROOT = 'dist-compat/'; |
| 13 | +const CJS_ROOT = ROOT + 'cjs/compat/'; |
| 14 | +const ESM5_ROOT = ROOT + 'esm5/compat/'; |
| 15 | +const ESM2015_ROOT = ROOT + 'esm2015/compat/'; |
| 16 | +const TYPE_ROOT = ROOT + 'typings/compat/'; |
| 17 | +const PKG_ROOT = ROOT + 'package/'; |
| 18 | +const CJS_PKG = PKG_ROOT + ''; |
| 19 | +const ESM5_PKG = PKG_ROOT + '_esm5/'; |
| 20 | +const ESM2015_PKG = PKG_ROOT + '_esm2015/'; |
| 21 | +const UMD_PKG = PKG_ROOT + 'bundles/'; |
| 22 | +const TYPE_PKG = PKG_ROOT; |
| 23 | + |
| 24 | +// License info for minified files |
| 25 | +let licenseUrl = 'https://github.com/ReactiveX/RxJS/blob/master/LICENSE.txt'; |
| 26 | +let license = 'Apache License 2.0 ' + licenseUrl; |
| 27 | + |
| 28 | +// Recreate the distribution folder |
| 29 | +fs.removeSync(PKG_ROOT); |
| 30 | +mkdirp.sync(PKG_ROOT); |
| 31 | + |
| 32 | +// Copy over the sources |
| 33 | +fs.copySync(TYPE_ROOT, TYPE_PKG); |
| 34 | +copySources(CJS_ROOT, CJS_PKG); |
| 35 | +copySources(ESM5_ROOT, ESM5_PKG, true); |
| 36 | +copySources(ESM2015_ROOT, ESM2015_PKG, true); |
| 37 | + |
| 38 | +fs.copySync('compat/package.json', PKG_ROOT + '/package.json'); |
| 39 | + |
| 40 | +function copySources(rootDir, packageDir, ignoreMissing) { |
| 41 | + // If we are ignoring missing directories, early return when source doesn't exist |
| 42 | + if (!fs.existsSync(rootDir)) { |
| 43 | + if (ignoreMissing) { |
| 44 | + return; |
| 45 | + } else { |
| 46 | + throw "Source root dir does not exist!"; |
| 47 | + } |
| 48 | + } |
| 49 | + // Copy over the CommonJS files |
| 50 | + fs.copySync(rootDir, packageDir); |
| 51 | + fs.copySync('./LICENSE.txt', packageDir + 'LICENSE.txt'); |
| 52 | + fs.copySync('./compat/README.md', packageDir + 'README.md'); |
| 53 | +} |
0 commit comments