From 74455bbe39797cab0f225d56d34c40f2216bfe88 Mon Sep 17 00:00:00 2001 From: Aryan Malik <88618913+Aryan9592@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:11:47 +0530 Subject: [PATCH] Create shelljs.js --- npm_Modules/ShellJs/shelljs.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 npm_Modules/ShellJs/shelljs.js diff --git a/npm_Modules/ShellJs/shelljs.js b/npm_Modules/ShellJs/shelljs.js new file mode 100644 index 0000000..28a54bb --- /dev/null +++ b/npm_Modules/ShellJs/shelljs.js @@ -0,0 +1,25 @@ +var shell = require('shelljs'); + +if (!shell.which('git')) { + shell.echo('Sorry, this script requires git'); + shell.exit(1); +} + +// Copy files to release dir +shell.rm('-rf', 'out/Release'); +shell.cp('-R', 'stuff/', 'out/Release'); + +// Replace macros in each .js file +shell.cd('lib'); +shell.ls('*.js').forEach(function (file) { + shell.sed('-i', 'BUILD_VERSION', 'v0.1.2', file); + shell.sed('-i', /^.*REMOVE_THIS_LINE.*$/, '', file); + shell.sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, shell.cat('macro.js'), file); +}); +shell.cd('..'); + +// Run external tool synchronously +if (shell.exec('git commit -am "Auto-commit"').code !== 0) { + shell.echo('Error: Git commit failed'); + shell.exit(1); +}