UNPKG

@speedy-js/depcost

Version:

[![npm version](https://badgen.net/npm/v/@speedy-js/depcost)](https://npm.im/@speedy-js/depcost)

24 lines (19 loc) 465 B
const { tmpdir } = require('os') const { join } = require('path') const { ensureDirSync } = require('fs-extra') const { TEMP_DIR_PREFIX } = require('./const') const ROOT_TMP_DIR = join(tmpdir(), TEMP_DIR_PREFIX) /** * Get tmp directory by timestamp. * * @return string */ function getTmpDirByTS() { const dir = join(ROOT_TMP_DIR, new Date().getTime().toString(16)) ensureDirSync(dir) return dir } module.exports = { getTmpDirByTS, ROOT_TMP_DIR, }