本文整理匯總了TypeScript中fs.mkdtempSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript mkdtempSync函數的具體用法?TypeScript mkdtempSync怎麽用?TypeScript mkdtempSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了mkdtempSync函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getNewLogDirectory
public async getNewLogDirectory(): Promise<string | undefined> {
const root = await this.context.logger.logDirectory;
try {
return fs.mkdtempSync(path.join(root, `tsserver-log-`));
} catch (e) {
return undefined;
}
}
示例2: getNewLogDirectory
public async getNewLogDirectory(): Promise<string | undefined> {
const root = this.logDirectory();
if (root) {
try {
return fs.mkdtempSync(path.join(root, `tsserver-log-`));
} catch (e) {
return undefined;
}
}
return undefined;
}
示例3: copyServiceFilesToTempFolder
// On some distributions, root is not allowed access the AppImage folder: copy the files to /tmp.
function copyServiceFilesToTempFolder() {
const tmp = fs.mkdtempSync('/tmp/');
console.log(`copying service files to ${tmp}`);
[LINUX_DAEMON_FILENAME, LINUX_DAEMON_SYSTEMD_SERVICE_FILENAME, LINUX_INSTALLER_FILENAME].forEach(
(filename) => {
const src = path.join(OUTLINE_PROXY_CONTROLLER_PATH, filename);
// https://github.com/jprichardson/node-fs-extra/issues/323
const dest = path.join(tmp, filename);
fsextra.copySync(src, dest, {overwrite: true});
});
return tmp;
}
示例4: createTestServerOption
export function createTestServerOption() {
const tmpDataPath = fs.mkdtempSync(path.join(os.tmpdir(), 'code_test'));
const config = {
get(key: string) {
if (key === 'path.data') {
return tmpDataPath;
}
},
};
return new ServerOptions(TEST_OPTIONS, config);
}
示例5: getPypircPath
export function getPypircPath(): string {
let pypircPath: string;
if (tl.getVariable("PYPIRC_PATH")) {
pypircPath = tl.getVariable("PYPIRC_PATH");
}
else {
let tempPath = tl.getVariable("Agent.TempDirectory");
tempPath = path.join(tempPath, "twineAuthenticate");
tl.mkdirP(tempPath);
let savePypircPath = fs.mkdtempSync(tempPath + path.sep);
pypircPath = savePypircPath + path.sep + ".pypirc";
}
return pypircPath;
}
示例6: getPypircPath
export function getPypircPath(): string {
let pypircPath: string;
if (tl.getVariable("PYPIRC_PATH")) {
pypircPath = tl.getVariable("PYPIRC_PATH");
}
else {
// tslint:disable-next-line:max-line-length
let tempPath = tl.getVariable("Agent.BuildDirectory") || tl.getVariable("Agent.ReleaseDirectory") || process.cwd();
tempPath = path.join(tempPath, "twineAuthenticate");
tl.mkdirP(tempPath);
let savePypircPath = fs.mkdtempSync(tempPath + path.sep);
pypircPath = savePypircPath + path.sep + ".pypirc";
}
return pypircPath;
}
示例7: zipLogs
function zipLogs(
logsPath: string
): Promise<string> {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vscode-log-upload'));
const outZip = path.join(tempDir, 'logs.zip');
return new Promise<string>((resolve, reject) => {
doZip(logsPath, outZip, tempDir, (err, stdout, stderr) => {
if (err) {
console.error(localize('zipError', 'Error zipping logs: {0}', err.message));
reject(err);
} else {
resolve(outZip);
}
});
});
}
示例8: start
public static start() : EtcdDaemon {
let ret = new EtcdDaemon();
ret.etcdir = fs.mkdtempSync("certor-test-")
console.log("CREATED:", ret.etcdir)
ret.etcd = cp.spawn('etcd', ['--data-dir', ret.etcdir])
ret.etcd.on('error', (err) => {
console.error("can't spawn etcd")
});
ret.etcd.stdin.on('data', (res: string) => {
//console.log(">>"+res+"<<")
})
ret.etcd.stderr.on('data', (res: string) => {
// console.log(">>"+res+"<<")
})
// WAIT FOR started
return ret;
}
示例9: describe
describe('repository service test', () => {
const log = new ConsoleLogger();
const baseDir = fs.mkdtempSync(path.join(os.tmpdir(), 'code_test'));
log.debug(baseDir);
const repoDir = path.join(baseDir, 'repo');
const credsDir = path.join(baseDir, 'credentials');
// @ts-ignore
before(() => {
fs.mkdirSync(credsDir);
fs.mkdirSync(repoDir);
});
// @ts-ignore
after(() => {
return rimraf.sync(baseDir);
});
const service = new RepositoryService(repoDir, credsDir, log, false /* enableGitCertCheck */);
it('can not clone a repo by ssh without a key', async () => {
const repo = RepositoryUtils.buildRepository(
'git@github.com:elastic/TypeScript-Node-Starter.git'
);
await assert.rejects(service.clone(repo));
// @ts-ignore
}).timeout(60000);
/* it('can clone a repo by ssh with a key', async () => {
const repo = RepositoryUtils.buildRepository('git@github.com:elastic/code.git');
const { publicKey, privateKey } = generateKeyPairSync('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'pkcs1',
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs1',
format: 'pem',
},
});
fs.writeFileSync(path.join(credsDir, 'id_rsa.pub'), publicKey);
fs.writeFileSync(path.join(credsDir, 'id_rsa'), privateKey);
const result = await service.clone(repo);
assert.ok(fs.existsSync(path.join(repoDir, result.repo.uri)));
}).timeout(60000); */
});
示例10: Promise
return new Promise((resolve, reject) => {
this.workingDir = fs.mkdtempSync(path.join(os.tmpdir(), "e2e-app"))
try {
if (fs.statSync(this.path).isDirectory()) {
for (const file of fs.readdirSync(this.path)) {
const src = path.join(this.path, file)
const dst = path.join(this.workingDir, file)
console.debug(`Copy file ${src} => ${dst}`)
fs.copyFileSync(src, dst)
}
} else {
const dst = path.join(this.workingDir, `index${path.extname(this.path)}`)
console.debug(`Copy file ${this.path} => ${dst}`)
fs.copyFileSync(this.path, dst)
}
} catch (err) {
console.warn(err)
reject(new Error("Error copying test app: " + err.toString()))
}
this.child = execa("../../fly", ["server", "-p", this.port.toString(), "--no-watch", this.workingDir], {
env: {
LOG_LEVEL: process.env.LOG_LEVEL,
FLY_ENV: "test",
HOST_ALIASES: JSON.stringify(aliasMap)
}
})
// this.child.on("exit", (code, signal) => {
// console.debug(`[${this.alias}] exit from signal ${signal}`, { code })
// })
this.child.on("error", err => {
console.warn(`[${this.alias}] process error`, { err })
})
this.child.stdout.on("data", chunk => {
console.debug(`[${this.alias}] ${chunk}`)
})
waitOn({ resources: [`tcp:${this.context.hostname}:${this.port}`], timeout: 10000 }).then(resolve, reject)
})