From 84a6ea9223e4eabbf1feac6cf7a71211f3404ce7 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 15 Jan 2021 00:51:42 +0800 Subject: [PATCH] fix(cli): mkdir -p is not valid command in powershell --- cli/src/create-npm-dir.ts | 6 ++++-- cli/src/new/index.ts | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/src/create-npm-dir.ts b/cli/src/create-npm-dir.ts index 3d352aeb..28cbfe44 100644 --- a/cli/src/create-npm-dir.ts +++ b/cli/src/create-npm-dir.ts @@ -1,3 +1,4 @@ +import { mkdirSync } from 'fs' import { join } from 'path' import chalk from 'chalk' @@ -7,7 +8,6 @@ import { pick } from 'lodash' import { getNapiConfig } from './consts' import { debugFactory } from './debug' import { PlatformDetail } from './parse-triple' -import { spawn } from './spawn' import { writeFileAsync } from './utils' const debug = debugFactory('create-npm-dir') @@ -38,7 +38,9 @@ export class CreateNpmDirCommand extends Command { 'npm', `${platformDetail.platformArchABI}`, ) - await spawn(`mkdir -p ${targetDir}`) + mkdirSync(targetDir, { + recursive: true, + }) const binaryFileName = `${binaryName}.${platformDetail.platformArchABI}.node` const targetPackageJson = join(targetDir, 'package.json') debug(`Write file [${chalk.yellowBright(targetPackageJson)}]`) diff --git a/cli/src/new/index.ts b/cli/src/new/index.ts index 618d9f23..ac179125 100644 --- a/cli/src/new/index.ts +++ b/cli/src/new/index.ts @@ -8,7 +8,6 @@ import inquirer, { prompt } from 'inquirer' import { CreateNpmDirCommand } from '../create-npm-dir' import { debugFactory } from '../debug' import { DefaultPlatforms } from '../parse-triple' -import { spawn } from '../spawn' import { createCargoContent } from './cargo' import { createCargoConfig } from './cargo-config' @@ -113,10 +112,9 @@ export class NewProjectCommand extends Command { this.enableGithubActions = answer[ENABLE_GITHUB_ACTIONS_PROMOTE_NAME] } - const command = `mkdir -p ${this.dirname}` debug(`Running command: ${chalk.green('[${command}]')}`) if (!this.dryRun) { - await spawn(command) + mkdirSync(join(process.cwd(), this.dirname!)) mkdirSync(join(process.cwd(), this.dirname!, 'src')) }