Skip to content

Add ability to disable scripts in package.json to avoid them being run on npm install #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BuildPackage.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ call "c:\Program Files (x86)\nodejs\nodevars.bat"
call npm.cmd install -g grunt-cli

set NATIVESCRIPT_SKIP_POSTINSTALL_TASKS=1
call grunt.cmd enableScripts:false
call npm.cmd install
call grunt.cmd enableScripts:true
set NATIVESCRIPT_SKIP_POSTINSTALL_TASKS=

call grunt.cmd pack --no-color
Expand Down
12 changes: 12 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ module.exports = function(grunt) {
grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
});

grunt.registerTask("enableScripts", function(enable) {
var enableTester = /false/i;
var newScriptsAttr = !enableTester.test(enable) ? "scripts" : "skippedScripts";
var packageJson = grunt.file.readJSON("package.json");
var oldScriptsAttrValue = packageJson.scripts || packageJson.skippedScripts;
delete packageJson.scripts;
delete packageJson.skippedScripts;
packageJson[newScriptsAttr] = oldScriptsAttrValue;
grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
});


grunt.registerTask("test", ["ts:devall", "shell:npm_test"]);
grunt.registerTask("pack", [
"clean",
Expand Down