From 1aec5455fc7738c8df354358e51bf4655c5ca861 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Thu, 16 Aug 2018 22:44:44 +0300 Subject: [PATCH] fix(kernel): can't find temp directory on Windows (#184) Use `os.tmpdir()` instead of `/tmp` when creating the kernel installation and staging directories. Fixes #183 --- packages/jsii-kernel/lib/kernel.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/jsii-kernel/lib/kernel.ts b/packages/jsii-kernel/lib/kernel.ts index f187ca7418..bcbd4e5ffc 100644 --- a/packages/jsii-kernel/lib/kernel.ts +++ b/packages/jsii-kernel/lib/kernel.ts @@ -1,5 +1,6 @@ import * as fs from 'fs-extra'; import * as spec from 'jsii-spec'; +import * as os from 'os'; import * as path from 'path'; import { SourceMapConsumer } from 'source-map'; import * as tar from 'tar'; @@ -73,7 +74,7 @@ export class Kernel { } if (!this.installDir) { - this.installDir = await fs.mkdtemp('/tmp/jsii-kernel-'); + this.installDir = await fs.mkdtemp(path.join(os.tmpdir(), 'jsii-kernel-')); await fs.mkdirp(path.join(this.installDir, 'node_modules')); this._debug('creating jsii-kernel modules workdir:', this.installDir); @@ -110,7 +111,7 @@ export class Kernel { } else { // untar the archive to a staging directory, read the jsii spec from it // and then move it to the node_modules directory of the kernel. - const staging = await fs.mkdtemp('/tmp/jsii-kernel-install-staging-'); + const staging = await fs.mkdtemp(path.join(os.tmpdir(), 'jsii-kernel-install-staging-')); try { await tar.extract({ strict: true, file: req.tarball, cwd: staging });