1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | 'use strict';
|
17 |
|
18 | const child_process = require('child_process');
|
19 | const colors = require('colors');
|
20 | const fs = require('fs');
|
21 | const path = require('path');
|
22 | const semver = require('semver')
|
23 |
|
24 | const packages = {};
|
25 | const fix = (process.argv.indexOf('--fix') !== -1);
|
26 |
|
27 | const npmDirectory = path.resolve('.');
|
28 | const npmConfigFile = path.resolve(npmDirectory, 'package.json');
|
29 | const npmConfig = require(npmConfigFile);
|
30 | const targetVersion = npmConfig.version;
|
31 | const targetDependency = `${targetVersion}`;
|
32 | packages['package.json'] = npmConfig;
|
33 |
|
34 | if (!semver.valid(targetVersion)) {
|
35 | console.error(`Error: the version "${targetVersion}" in "${npmConfigFile}" is invalid!`);
|
36 | process.exit(1);
|
37 | }
|
38 |
|
39 | const masterPackageFile = path.resolve(npmDirectory, 'package.json');
|
40 | const masterPackage = require(masterPackageFile);
|
41 | packages['package.json'] = masterPackage;
|
42 |
|