Skip to content

Commit

Permalink
feat: only install skeleton dependencies, not devDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Apr 26, 2019
1 parent b6e7f23 commit b307b16
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/skeleton-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ module.exports = async function(dir, {
const metaFile = path.join(dir, 'package.json');
if (fileExists(metaFile)) {
const meta = JSON.parse(fs.readFileSync(metaFile, 'utf8'));
if ((meta.dependencies && Object.keys(meta.dependencies).length) ||
(meta.devDependencies && Object.keys(meta.devDependencies).length)) {
if (meta.dependencies && Object.keys(meta.dependencies).length) {
await _npmInstall(dir);
}
}
Expand Down Expand Up @@ -62,7 +61,7 @@ function npmInstall(dir) {
return new Promise((resolve, reject) => {
spawn(
dir,
['npm', 'i'],
['npm', 'i', '--only=prod'],
{ stdio: 'inherit', cwd: dir }
).on('close', resolve).on('error', reject);
});
Expand Down
23 changes: 23 additions & 0 deletions test/skeleton-config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ test.serial('skeletonConfig runs npm install when required', async t => {
});
});

test.serial('skeletonConfig does not run npm install for devDependencies', async t => {
mockfs({
'skeleton/package.json': '{"devDpendencies":{"foo":"1.0.0"}}'
});

let installed;
function npmInstall(dir) {
installed = dir;
}

const result = await config('skeleton', {_npmInstall: npmInstall});
t.falsy(installed);
t.deepEqual(result, {
questions: [{
name: 'name',
message: 'Please name this project:',
default: 'my-app'
}],
prependTransforms: [],
appendTransforms: []
});
});

test.serial('skeletonConfig skip npm install when not required', async t => {
mockfs({
'skeleton/package.json': '{}'
Expand Down

0 comments on commit b307b16

Please sign in to comment.