jenkins snippet set ci script

This commit is contained in:
Timo Hocker 2020-03-04 12:59:16 +01:00
parent 8c47eef18f
commit b81f7349ef

View File

@ -20,10 +20,12 @@ const path = require ('path');
* @param {Array} args function arguments
*/
function run (folder, args) {
const is_node = args.length === 1 && (/^node$/ui).test (args[0]);
const template = path.join (
__dirname,
'template',
args.length === 1 && (/^node$/ui).test
is_node
? 'node'
: 'general'
);
@ -35,6 +37,15 @@ function run (folder, args) {
{ filter: (src, dest) => !fs.existsSync (dest) }
);
}
if (is_node) {
const pkg = path.join (folder, 'package.json');
if (fs.existsSync (pkg)) {
const json = JSON.parse (fs.readFileSync (pkg, 'utf-8'));
json.scripts.ci = 'yarn && node jenkins.js';
fs.writeFileSync (pkg, JSON.stringify (json, null, 2), 'utf-8');
}
}
}
/**