From 5df9395613cf59d56bc90ba75afe9cab6d463199 Mon Sep 17 00:00:00 2001 From: GuangWong Date: Thu, 20 Sep 2018 11:32:29 +0800 Subject: [PATCH] chore: custom tmp dir --- packages/messenger/src/base.ts | 2 +- packages/pandora/src/application/ProcfileReconciler.ts | 5 +++-- packages/pandora/src/daemon/DaemonHandler.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/messenger/src/base.ts b/packages/messenger/src/base.ts index 9f497a76..322e9eab 100644 --- a/packages/messenger/src/base.ts +++ b/packages/messenger/src/base.ts @@ -4,7 +4,7 @@ import assert = require('assert'); import eventName from './eventName'; import * as os from 'os'; import * as path from 'path'; -const tmpDir = os.tmpdir(); +const tmpDir = process.env.PANDORA_TMP_DIR || os.tmpdir(); const sockPath = Symbol('sockpath'); class MessengerBase extends Base { diff --git a/packages/pandora/src/application/ProcfileReconciler.ts b/packages/pandora/src/application/ProcfileReconciler.ts index 5aa957fc..7b12fec8 100644 --- a/packages/pandora/src/application/ProcfileReconciler.ts +++ b/packages/pandora/src/application/ProcfileReconciler.ts @@ -13,8 +13,9 @@ import {ProcfileReconcilerAccessor} from './ProcfileReconcilerAccessor'; import {exec} from 'child_process'; import uuid = require('uuid'); import mzFs = require('mz/fs'); -import {tmpdir} from 'os'; +import * as os from 'os'; +const tmpdir = process.env.PANDORA_TMP_DIR || os.tmpdir(); const foundAll = Symbol(); /** @@ -402,7 +403,7 @@ export class ProcfileReconciler { */ public static async getStructureViaNewProcess(appRepresentation: ApplicationRepresentation): Promise { - const tmpFile = join(tmpdir(), uuid.v4()); + const tmpFile = join(tmpdir, uuid.v4()); const isTs = /\.ts$/.test(__filename); await new Promise((resolve, reject) => { diff --git a/packages/pandora/src/daemon/DaemonHandler.ts b/packages/pandora/src/daemon/DaemonHandler.ts index 2652dae6..03e31be7 100644 --- a/packages/pandora/src/daemon/DaemonHandler.ts +++ b/packages/pandora/src/daemon/DaemonHandler.ts @@ -13,7 +13,7 @@ import mkdirp = require('mkdirp'); const {consoleLogger} = require('../../cli/util/cliUtils'); const is = require('is-type-of'); -const tmpDir = os.tmpdir(); +const tmpDir = process.env.PANDORA_TMP_DIR || os.tmpdir(); const pidFile = path.join(tmpDir, 'nodejs_pandora.pid'); const pathDaemonBootstrap = require.resolve('./DaemonBootstrap'); let preparedClient: MessengerClient = null;