-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
46 lines (36 loc) · 1.34 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const childProcess = require('child_process');
const fs = require('fs-extra');
const gulp = require('gulp');
var minimist = require('minimist');
var knownOptions = { string: 'version' };
var options = minimist(process.argv.slice(2), knownOptions);
gulp.task('publish', function () {
const command = "npm publish --access=public"
childProcess.execSync(command, { stdio: [0, 1, 2], cwd: './packages/libzy/' });
childProcess.execSync(command, { stdio: [0, 1, 2], cwd: './packages/libzy-lib/' });
});
gulp.task('version', function () {
const newVersion = options.version;
if (!newVersion) {
console.error('Please specify version parameter!');
return;
}
updateVersion('./packages/libzy/package.json', newVersion);
updateVersion('./packages/libzy-lib/package.json', newVersion);
});
gulp.task('versions', function () {
const print = (project) => {
console.log(project + ": " + require('./packages/' + project + '/package.json').version);
}
print('libzy');
print('libzy-lib');
});
const updateVersion = (path, version) => {
const package = require(path);
console.log(package.name + " old version is " + package.version);
package.version = version;
if (package.dependencies["libzy-lib"])
package.dependencies["libzy-lib"] = version;
const data = JSON.stringify(package, null, "\t");
fs.writeFileSync(path, data);
}