From 4044cef8dde6ae0a1dd4047b3e1832200cd6880d Mon Sep 17 00:00:00 2001 From: Florian Richter Date: Thu, 9 Jan 2020 12:32:08 +0100 Subject: [PATCH 1/5] Avoid using prefix flag, instead use cwd of execa --- src/commands/package.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands/package.ts b/src/commands/package.ts index 0b1811d6..22aaf4bd 100644 --- a/src/commands/package.ts +++ b/src/commands/package.ts @@ -103,9 +103,10 @@ export default class Package extends Command { title: 'Install productive dependencies', enabled: () => !flags.skipInstall, task: async () => - execa('npm', ['install', '--production', '--prefix', outputDir], { stdio: flags.verbose ? 'inherit' : 'ignore' }).catch(e => - this.error(e, { exit: 10 }) - ) + execa('npm', ['install', '--production'], { + cwd: path.resolve('outputDir'), + stdio: flags.verbose ? 'inherit' : 'ignore' + }).catch(e => this.error(e, { exit: 10 })) } ]); From 8184b04cebc7e68cfc2cf4bb16699ecfca89f266 Mon Sep 17 00:00:00 2001 From: Florian Richter Date: Thu, 9 Jan 2020 12:32:49 +0100 Subject: [PATCH 2/5] Alternative solution with --force --- src/commands/package.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/commands/package.ts b/src/commands/package.ts index 22aaf4bd..b3e870d8 100644 --- a/src/commands/package.ts +++ b/src/commands/package.ts @@ -103,10 +103,9 @@ export default class Package extends Command { title: 'Install productive dependencies', enabled: () => !flags.skipInstall, task: async () => - execa('npm', ['install', '--production'], { - cwd: path.resolve('outputDir'), - stdio: flags.verbose ? 'inherit' : 'ignore' - }).catch(e => this.error(e, { exit: 10 })) + execa('npm', ['install', '--production', '--prefix', outputDir, '--force'], { stdio: flags.verbose ? 'inherit' : 'ignore' }).catch(e => + this.error(e, { exit: 10 }) + ) } ]); From c28e1a733305be9e2b8d4990ffd0695f20635d12 Mon Sep 17 00:00:00 2001 From: Florian Richter Date: Thu, 9 Jan 2020 13:15:59 +0100 Subject: [PATCH 3/5] Run with force on win32 --- src/commands/package.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/commands/package.ts b/src/commands/package.ts index b3e870d8..dcf645ac 100644 --- a/src/commands/package.ts +++ b/src/commands/package.ts @@ -7,6 +7,7 @@ import * as execa from 'execa'; import * as glob from 'fast-glob'; import * as fs from 'fs'; import * as Listr from 'listr'; +import { platform } from 'os'; import * as path from 'path'; import * as rm from 'rimraf'; @@ -103,9 +104,10 @@ export default class Package extends Command { title: 'Install productive dependencies', enabled: () => !flags.skipInstall, task: async () => - execa('npm', ['install', '--production', '--prefix', outputDir, '--force'], { stdio: flags.verbose ? 'inherit' : 'ignore' }).catch(e => - this.error(e, { exit: 10 }) - ) + execa('npm', ['install', '--production', platform() === 'win32' ? '--force' : ''], { + cwd: 'outputDir', + stdio: flags.verbose ? 'inherit' : 'ignore' + }).catch(e => this.error(e, { exit: 10 })) } ]); From cabaf7026b931ee931eb370c039c3b7109f46a5b Mon Sep 17 00:00:00 2001 From: Florian Richter Date: Thu, 9 Jan 2020 13:26:15 +0100 Subject: [PATCH 4/5] Fix cwd for execa --- src/commands/package.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/package.ts b/src/commands/package.ts index dcf645ac..d5e22958 100644 --- a/src/commands/package.ts +++ b/src/commands/package.ts @@ -105,7 +105,7 @@ export default class Package extends Command { enabled: () => !flags.skipInstall, task: async () => execa('npm', ['install', '--production', platform() === 'win32' ? '--force' : ''], { - cwd: 'outputDir', + cwd: path.resolve(projectDir, 'outputDir'), stdio: flags.verbose ? 'inherit' : 'ignore' }).catch(e => this.error(e, { exit: 10 })) } From 64730d140fbd1aad334aa71755582f617d2aa7d4 Mon Sep 17 00:00:00 2001 From: Florian Richter Date: Thu, 9 Jan 2020 13:35:38 +0100 Subject: [PATCH 5/5] Go back to using prefix --- src/commands/package.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/commands/package.ts b/src/commands/package.ts index d5e22958..822484c0 100644 --- a/src/commands/package.ts +++ b/src/commands/package.ts @@ -104,8 +104,7 @@ export default class Package extends Command { title: 'Install productive dependencies', enabled: () => !flags.skipInstall, task: async () => - execa('npm', ['install', '--production', platform() === 'win32' ? '--force' : ''], { - cwd: path.resolve(projectDir, 'outputDir'), + execa('npm', ['install', '--production', `--prefix=${outputDir}`, ...(platform() === 'win32' ? ['--force'] : [])], { stdio: flags.verbose ? 'inherit' : 'ignore' }).catch(e => this.error(e, { exit: 10 })) }