"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.temporalDir=void 0;var _ora=_interopRequireDefault(require("ora"));
var _fs=_interopRequireDefault(require("fs"));
var _path=_interopRequireDefault(require("path"));
var _index=require("../../index");var _getProjectEnv$tempor,_getProjectEnv;

const temporalPath=(_getProjectEnv$tempor=(_getProjectEnv=(0,_index.getProjectEnv)())===null||_getProjectEnv===void 0?void 0:_getProjectEnv.temporalsDirectory)!==null&&_getProjectEnv$tempor!==void 0?_getProjectEnv$tempor:_path.default.resolve(`${process.cwd()}/.corenode_tmp`);
const spinner=(0,_ora.default)({

spinner:"dots",
text:"Initalizing..."});


const temporalDir={
createNew:name=>{
let newTemporalPath=_path.default.resolve(process.cwd(),`${temporalPath}/${name!==null&&name!==void 0?name:""}_${new Date().getTime()}`);

if(!_fs.default.existsSync(newTemporalPath)){
_fs.default.mkdir(newTemporalPath,{recursive:true},e=>{
if(e)throw new Error(e);
});
return newTemporalPath;
}
return null;
},
getTemporalsPath:()=>{
return temporalPath;
},
clean:()=>{
spinner.start("Cleaning up temporal files...");
_fs.default.rmdirSync(temporalPath,{recursive:true});
spinner.succeed();
}};exports.temporalDir=temporalDir;var _default=


temporalDir;exports.default=_default;