Skip to content

Commit bb038a0

Browse files
Merge pull request #1150 from pattern-lab/new-dir-init
fix(cli): set current working directory before scaffolded npm init
2 parents aef661a + 5993ebb commit bb038a0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/cli/bin/scaffold.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ const mkdirsAsync = require('./utils').mkdirsAsync;
1616
*/
1717
const scaffold = (projectDir, sourceDir, publicDir, exportDir) =>
1818
wrapAsync(function*() {
19-
if (!fs.existsSync(path.resolve(projectDir, 'package.json'))) {
20-
execa.sync('npm', ['init', '-y']);
19+
const projectPath = path.join(process.cwd(), projectDir);
20+
if (!fs.existsSync(path.join(projectPath, 'package.json'))) {
21+
execa.sync('npm', ['init', '-y'], {
22+
cwd: projectPath,
23+
});
2124
}
2225
/**
2326
* Create mandatory files structure

0 commit comments

Comments
 (0)