Merge pull request #424 from napi-rs/fix-windows

fix(cli): mkdir -p is not valid command in powershell
This commit is contained in:
LongYinan 2021-01-15 01:30:07 +08:00 committed by GitHub
commit 260ff1decd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -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)}]`)

View file

@ -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'))
}