diff --git a/src/LocalInstaller.ts b/src/LocalInstaller.ts index b6d3bb9..916543a 100644 --- a/src/LocalInstaller.ts +++ b/src/LocalInstaller.ts @@ -24,6 +24,10 @@ export interface ListByPackage { } const TEN_MEGA_BYTE = 1024 * 1024 * 10; + +function quotify(value: string) { + return `"${value}"`; +} export class LocalInstaller extends EventEmitter { private sourcesByTarget: ListByPackage; private options: Options; @@ -81,7 +85,10 @@ export class LocalInstaller extends EventEmitter { } private installOne(target: InstallTarget): Promise { - const toInstall = target.sources.map(source => resolvePackFile(this.uniqueDir, source.packageJson)).join(' '); + const toInstall = target.sources + .map(source => resolvePackFile(this.uniqueDir, source.packageJson)) + .map(quotify) + .join(' '); const options: ExecOptions = { cwd: target.directory, maxBuffer: TEN_MEGA_BYTE @@ -125,7 +132,7 @@ export class LocalInstaller extends EventEmitter { } private packOne(directory: string): Promise { - return exec(`npm pack ${directory}`, { cwd: this.uniqueDir, maxBuffer: TEN_MEGA_BYTE }) + return exec(`npm pack ${quotify(directory)}`, { cwd: this.uniqueDir, maxBuffer: TEN_MEGA_BYTE }) .then(() => void this.emit('packed', directory)); } diff --git a/test/unit/LocalInstallerSpec.ts b/test/unit/LocalInstallerSpec.ts index e1201cb..746ade8 100644 --- a/test/unit/LocalInstallerSpec.ts +++ b/test/unit/LocalInstallerSpec.ts @@ -50,9 +50,9 @@ describe('LocalInstaller install', () => { it('should pack correct packages', async () => { await sut.install(); - expect(execStub).calledWith(`npm pack ${resolve('b')}`, { cwd: tmpDir, maxBuffer: TEN_MEGA_BYTE }); - expect(execStub).calledWith(`npm pack ${resolve('c')}`, { cwd: tmpDir, maxBuffer: TEN_MEGA_BYTE }); - expect(execStub).calledWith(`npm pack ${resolve('/e')}`, { cwd: tmpDir, maxBuffer: TEN_MEGA_BYTE }); + expect(execStub).calledWith(`npm pack "${resolve('b')}"`, { cwd: tmpDir, maxBuffer: TEN_MEGA_BYTE }); + expect(execStub).calledWith(`npm pack "${resolve('c')}"`, { cwd: tmpDir, maxBuffer: TEN_MEGA_BYTE }); + expect(execStub).calledWith(`npm pack "${resolve('/e')}"`, { cwd: tmpDir, maxBuffer: TEN_MEGA_BYTE }); }); it('should install correct packages', async () => { @@ -157,7 +157,7 @@ describe('LocalInstaller install', () => { }); }); - const tmp = (file: string) => resolve(tmpDir, file); + const tmp = (file: string) => `"${resolve(tmpDir, file)}"`; const stubPackageJson = (recipe: { [directory: string]: string }) => { Object.keys(recipe).forEach((directory, i) => {