Skip to content

Commit

Permalink
Merge pull request #1150 from pattern-lab/new-dir-init
Browse files Browse the repository at this point in the history
fix(cli): set current working directory before scaffolded npm init
  • Loading branch information
bmuenzenmeyer authored Apr 24, 2020
2 parents aef661a + 5993ebb commit bb038a0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/cli/bin/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ const mkdirsAsync = require('./utils').mkdirsAsync;
*/
const scaffold = (projectDir, sourceDir, publicDir, exportDir) =>
wrapAsync(function*() {
if (!fs.existsSync(path.resolve(projectDir, 'package.json'))) {
execa.sync('npm', ['init', '-y']);
const projectPath = path.join(process.cwd(), projectDir);
if (!fs.existsSync(path.join(projectPath, 'package.json'))) {
execa.sync('npm', ['init', '-y'], {
cwd: projectPath,
});
}
/**
* Create mandatory files structure
Expand Down

0 comments on commit bb038a0

Please sign in to comment.