From c1b3dfadd2e53062a892dc036bc401bad924ce46 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 27 Apr 2019 14:04:04 +0800 Subject: [PATCH] removeExceptGitDir --- public/react/scripts/build.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/public/react/scripts/build.js b/public/react/scripts/build.js index cf7c1377..6dd9d3e5 100644 --- a/public/react/scripts/build.js +++ b/public/react/scripts/build.js @@ -44,16 +44,16 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { } function removeExceptGitDir(dir) { - fs2.readdir(dir, function(err, list) { - if (err) return done(err); - var pending = list.length; - if (!pending) return done(null, results); - list.forEach(function(file) { - if (file.indexOf('.git') == -1) { - file = path.resolve(dir, file); - fs.remove(file) - } - }); + // readdirSync + const list = fs2.readdirSync(dir) + // if (err) return done(err); + var pending = list.length; + // if (!pending) return done(null, results); + list.forEach(function(file) { + if (file.indexOf('.git') == -1) { + file = path.resolve(dir, file); + fs.removeSync(file) + } }); } @@ -202,6 +202,14 @@ function generateNewIndexJsp() { fs2.writeFile(outputPath, result, 'utf8', function (err) { if (err) return console.log(err); + commitAndPush(); }); }); +} + +function commitAndPush() { + var exec = require('child_process').exec; + function puts(error, stdout, stderr) { console.log(stdout) } + var options = {cwd:"./build"}; + exec("git status && git commit -am 'b' && git push", options, puts); } \ No newline at end of file