From 42c0d809147e6fe660c7f10d03d1835047be9cd6 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 28 Nov 2020 13:13:14 +0000 Subject: [PATCH] plugins: checkPlugin script includes remove node_modules if committed. --- bin/plugins/checkPlugin.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/plugins/checkPlugin.js b/bin/plugins/checkPlugin.js index a96176ca1..523fe11c5 100755 --- a/bin/plugins/checkPlugin.js +++ b/bin/plugins/checkPlugin.js @@ -317,7 +317,7 @@ fs.readdir(pluginPath, (err, rootFiles) => { console.log('updating .travis.yml'); fs.writeFileSync(`${pluginPath}/.travis.yml`, travisConfig); hasAutoFixed = true; - } + }// } if (files.indexOf('.gitignore') === -1) { @@ -328,6 +328,17 @@ fs.readdir(pluginPath, (err, rootFiles) => { const gitignore = fs.readFileSync('bin/plugins/lib/gitignore', {encoding: 'utf8', flag: 'r'}); fs.writeFileSync(`${pluginPath}/.gitignore`, gitignore); } + }else{ + let gitignore = + fs.readFileSync(`${pluginPath}/.gitignore`, {encoding: 'utf8', flag: 'r'}); + if(gitignore.indexOf("node_modules/") === -1){ + console.warn("node_modules/ missing from .gitignore") + if(autoFix){ + gitignore += "node_modules/"; + fs.writeFileSync(`${pluginPath}/.gitignore`, gitignore); + hasAutoFixed = true; + } + } } // if we include templates but don't have translations... @@ -391,7 +402,7 @@ fs.readdir(pluginPath, (err, rootFiles) => { // holy shit you brave. console.log('Attempting autocommit and auto publish to npm'); // github should push to npm for us :) - exec(`cd node_modules/${pluginName} && git add -A && git commit --allow-empty -m 'autofixes from Etherpad checkPlugins.js' && git push && cd ../..`, (error, name, stderr) => { + exec(`cd node_modules/${pluginName} && git rm -rf node_modules --ignore-unmatch && git add -A && git commit --allow-empty -m 'autofixes from Etherpad checkPlugins.js' && git push && cd ../..`, (error, name, stderr) => { if (error) { console.log(`error: ${error.message}`); return;