Skip to content

Commit

Permalink
Merge pull request elastic#5 from epixa/fix-shrinkwrap
Browse files Browse the repository at this point in the history
Create shrinkwrap from build
  • Loading branch information
rashidkpc committed Sep 17, 2015
2 parents 62a136c + 690d204 commit 44bfe2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
4 changes: 1 addition & 3 deletions tasks/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = function (grunt) {
let { flatten } = require('lodash');

grunt.registerTask('build', flatten([
'_build:shrinkwrap:ensureExists:true',
'_build:getProps',
'clean:build',
'clean:target',
Expand All @@ -13,9 +12,8 @@ module.exports = function (grunt) {
'_build:installedPlugins',
'_build:packageJson',
'_build:readme',
'_build:shrinkwrap:copyToBuild',
'_build:shrinkwrap:cleanup',
'_build:installNpmDeps',
'_build:shrinkwrap:ensureExists:true',
'clean:testsFromModules',
'clean:deepModuleBins',
'clean:deepModules',
Expand Down
24 changes: 3 additions & 21 deletions tasks/build/shrinkwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ module.exports = function (grunt) {
let { config } = grunt;
let { statSync } = require('fs');
let { join } = require('path');
let exec = (...args) => require('../utils/exec')(...args, { cwd: config.get('root') });
let buildDir = join(config.get('root'), 'build', 'kibana');
let exec = (...args) => require('../utils/exec')(...args, { cwd: buildDir });
let newFiles = [];
let shrinkwrapFile = join(config.get('root'), 'npm-shrinkwrap.json');
let shrinkwrapFile = join(buildDir, 'npm-shrinkwrap.json');

grunt.registerTask('_build:shrinkwrap:ensureExists', function (createIfMissing) {
try {
Expand All @@ -19,23 +20,4 @@ module.exports = function (grunt) {
else grunt.fail.warn('Releases require an npm-shrinkwrap.json file to exist');
}
});

grunt.registerTask('_build:shrinkwrap:copyToBuild', function () {
// this.requires(['_build:shrinkwrap:ensureExists', 'copy:devSource']);

// backup shrinkwrap and copy to build
exec('cp', ['npm-shrinkwrap.json', 'npm-shrinkwrap.dev']);
exec('cp', ['npm-shrinkwrap.json', join(config.get('root'), 'build', 'kibana', 'npm-shrinkwrap.build.json')]);

// create shrinkwrap without dev dependencies and copy to build
exec('npm', ['shrinkwrap', '--loglevel', 'error']);
exec('cp', ['npm-shrinkwrap.json', join(config.get('root'), 'build', 'kibana', 'npm-shrinkwrap.json')]);

// restore the dev shrinkwrap
exec('mv', ['npm-shrinkwrap.dev', 'npm-shrinkwrap.json']);
});

grunt.registerTask('_build:shrinkwrap:cleanup', function () {
if (newFiles.length) exec('rm', newFiles.splice(0));
});
};

0 comments on commit 44bfe2b

Please sign in to comment.