Browse Source

update the function for updating version in package.json files.

oldj 9 years ago
parent
commit
e985a8b15d
1 changed files with 10 additions and 6 deletions
  1. 10 6
      gulpfile.js

+ 10 - 6
gulpfile.js

@@ -34,13 +34,17 @@ gulp.task('ver', () => {
     let cnt = `exports.version = ${JSON.stringify(version)};`;
     fs.writeFileSync(fn, cnt, 'utf-8');
 
+    function updatePackage(fn) {
+        cnt = fs.readFileSync(fn);
+        let d = JSON.parse(cnt);
+        d.version = version.slice(0, 3).join('.');
+        cnt = beautify(JSON.stringify(d), {indent_size: 2});
+        fs.writeFileSync(fn, cnt, 'utf-8');
+    }
+
     // update package.json
-    fn = './package.json';
-    cnt = fs.readFileSync(fn);
-    let d = JSON.parse(cnt);
-    d.version = version.slice(0, 3).join('.');
-    cnt = beautify(JSON.stringify(d), {indent_size: 2});
-    fs.writeFileSync(fn, cnt, 'utf-8');
+    updatePackage(path.join(__dirname, 'package.json'));
+    updatePackage(path.join(__dirname, 'app', 'package.json'));
 });
 
 gulp.task('pack', () => {