Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
add npm install --production script to grunt build
Browse files Browse the repository at this point in the history
  • Loading branch information
zaggino committed Aug 24, 2016
1 parent 9077970 commit 4e17c98
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ module.exports = function (grunt) {
/*'cssmin',*/
/*'uglify',*/
'copy',
'npm-install',
'cleanempty',
'usemin',
'build-config'
Expand Down
4 changes: 4 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"branch": "",
"SHA": ""
},
"dependencies": {
"anymatch": "1.3.0",
"chokidar": "1.6.0"
},
"devDependencies": {
"grunt": "0.4.5",
"jasmine-node": "1.11.0",
Expand Down
52 changes: 52 additions & 0 deletions tasks/npm-install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2013 - present Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/

/*jslint node: true */

module.exports = function (grunt) {
"use strict";

var common = require("./lib/common")(grunt),
build = require("./build")(grunt);

// task: write-config
grunt.registerTask("npm-install", "Install node_modules to the dist folder so it gets bundled with release", function () {
var packageJSON = grunt.file.readJSON("package.json");
delete packageJSON.devDependencies;
delete packageJSON.scripts; // we don't want to run post-install scripts in dist folder
common.writeJSON(grunt, "dist/package.json", packageJSON);

var exec = require('child_process').exec;
var done = this.async();
exec('npm install --production', { cwd: './dist' }, function(err, stdout, stderr) {
if (err) {
grunt.log.error(stderr);
done(false);
} else {
grunt.log.writeln(stdout);
done();
}
});
});

};

0 comments on commit 4e17c98

Please sign in to comment.