feat(cli): support --cargo-cwd flag
This commit is contained in:
parent
91e21ce3a0
commit
5f2bea0b97
1 changed files with 10 additions and 3 deletions
|
@ -38,6 +38,9 @@ export class BuildCommand extends Command {
|
|||
@Command.String('--cargo-flags')
|
||||
cargoFlags = ''
|
||||
|
||||
@Command.String('--cargo-cwd')
|
||||
cargoCwd!: string
|
||||
|
||||
@Command.String({
|
||||
required: false,
|
||||
})
|
||||
|
@ -45,6 +48,9 @@ export class BuildCommand extends Command {
|
|||
|
||||
@Command.Path('build')
|
||||
async execute() {
|
||||
const cwd = this.cargoCwd
|
||||
? join(process.cwd(), this.cargoCwd)
|
||||
: process.cwd()
|
||||
const releaseFlag = this.isRelease ? `--release` : ''
|
||||
const targetFLag = this.targetTripleDir
|
||||
? `--target ${this.targetTripleDir}`
|
||||
|
@ -71,6 +77,7 @@ export class BuildCommand extends Command {
|
|||
execSync(cargoCommand, {
|
||||
env: process.env,
|
||||
stdio: 'inherit',
|
||||
cwd,
|
||||
})
|
||||
const { binaryName } = getNapiConfig(this.configFileName)
|
||||
let dylibName = this.cargoName
|
||||
|
@ -80,11 +87,11 @@ export class BuildCommand extends Command {
|
|||
try {
|
||||
debug('Start read toml')
|
||||
tomlContentString = await readFileAsync(
|
||||
join(process.cwd(), 'Cargo.toml'),
|
||||
join(cwd, 'Cargo.toml'),
|
||||
'utf-8',
|
||||
)
|
||||
} catch {
|
||||
throw new TypeError(`Could not find Cargo.toml in ${process.cwd()}`)
|
||||
throw new TypeError(`Could not find Cargo.toml in ${cwd}`)
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -151,7 +158,7 @@ export class BuildCommand extends Command {
|
|||
distModulePath = `${distModulePath}${platformName}.node`
|
||||
}
|
||||
|
||||
const dir = await findUp()
|
||||
const dir = await findUp(cwd)
|
||||
|
||||
if (!dir) {
|
||||
throw new TypeError('No target dir found')
|
||||
|
|
Loading…
Reference in a new issue