it('should empty output path', function() { // given fse.mkdirsSync(mockConfig.build.outputPath); const testFile = `${mockConfig.build.outputPath}/test.txt`; fse.writeFileSync(testFile, 'test'); // when nanogen.build(mockConfig); //then expect(fse.existsSync(testFile)).to.be.false; });
function k(a = '', b = '') { let d = e(a); c.existsSync(d) || c.mkdirsSync(d), c.writeFileSync(a, b); }
static getTempDirectory() { if (Command.APP_NAME === null) { throw Error('No app name set'); } try { fs.statSync(paths.temp); } catch (e) { fs.mkdirsSync(paths.temp); } return paths.temp; }
function FileSessionHandler(path) { /** * The path where sessions should be stored. * * @type {String} */ this.__path = path; /** * Create directory for session storage. */ fs.mkdirsSync(this.__path); }
/* Create directory */ router.post('/createdir', function(req, res) { try { fs.mkdirsSync(path.join(serverRoot, req.body.d, req.body.n)); res.send({ res: "ok", msg: "Success" }); } catch (err) { res.send({ res:"error", msg: err }); } });
/** * Write data to a file, relative to '.data' sub folder. * * @param {string} p The path of the file. * @param {any} data The data write. */ protected writeFile(p: string, data: any) { if (!data) { data = Buffer.alloc(0); } if (!Buffer.isBuffer(data)) { data = Buffer.from( ego_helpers.toStringSafe(data), 'utf8' ); } p = this.toFullDataPath(p); // keep sure directory exists const DIR = path.dirname(p); if (!fsExtra.existsSync(DIR)) { fsExtra.mkdirsSync(DIR); } fsExtra.writeFileSync(p, data); }
const writeTestProject = () => { fs.mkdirsSync(join(__dirname, 'test_project')) fs.mkdirsSync(join(__dirname, 'test_project', '.git')) fs.mkdirsSync(join(__dirname, 'test_project', 'node_modules')) fs.writeFileSync(join(__dirname, 'test_project', 'package.json'), JSON.stringify(PACKAGE_FILE, null, 2)) }
/* Dropzone COMPONENT ajax upload file */ router.post('/file_upload', block_access.actionAccessMiddleware("COMPONENT_NAME_URL", "create"), function(req, res) { // FONCTION UPLOAD DE FICHIER DE MULTER ( FICHIER DANS req.file ) upload(req, res, function(err) { if (err) { res.status(415); return res.json({ success: false, error: "An error occured." }); } fse.mkdirsSync(config.localstorage+req.body.dataSource+"/"+req.body.dataSourceID+"/"+req.body.dataComponent); var uploadPath = config.localstorage+req.body.dataSource+"/"+req.body.dataSourceID+"/"+req.body.dataComponent+"/"+req.file.originalname; var byte; var outStream = fs.createWriteStream(uploadPath); outStream.write(req.file.buffer); outStream.end(); outStream.on('finish', function(err){ res.json({ success: true }); }); }); });
/** * Returns the possible '.ego' folder inside the user's home directory. * * @param {boolean} [create] Create folder, if it does not exist. * * @return {string} The full path of the '.ego' folder. */ export function getEGOFolder(create = true): string { const FOLDER_PATH = path.resolve( path.join( os.homedir(), '.ego' ) ); if (create) { if (!fs.existsSync(FOLDER_PATH)) { fs.mkdirsSync(FOLDER_PATH); } } return FOLDER_PATH; }
/** * Creates a new temp file, inside the '.temp' sub folder. * * @return {string} The full path of the new file. */ protected createTempFile(): string { const TEMP_DIR = this.getTempDir(); if (!fsExtra.existsSync(TEMP_DIR)) { fsExtra.mkdirsSync(TEMP_DIR); } const TEMP_FILE = tmp.tmpNameSync({ dir: TEMP_DIR, }); fsExtra.writeFileSync( TEMP_FILE, Buffer.alloc(0) ); return TEMP_FILE; }
static getCacheDirectory() { if (Command.APP_NAME === null) { throw Error('No app name set'); } try { fs.statSync(paths.cache); } catch (e) { fs.mkdirsSync(paths.cache); } return paths.cache; }
function _createLogFile(fileName) { let filePath = path.join(LOG_FOLDER, fileName + '.log'); if (!fs.existsSync(LOG_FOLDER)) fs.mkdirsSync(LOG_FOLDER); fs.writeFileSync(filePath, ''); let lines = []; return { appendLine, write }; /** @param {string} line */ function appendLine(line) { // const escaped = line.match(/\033\[[\d;]+m/g); // console.log(line); lines.push(line); } function write(then) { fs.writeFile(filePath, lines.join('\n'), then); } }
static getConfigDirectory() { if (Command.APP_NAME === null) { throw Error('No app name set'); } try { fs.statSync(paths.config); } catch (e) { fs.mkdirsSync(paths.config); } return paths.config; }
/** * Creates the extension's folder in the home directory, if it does not exist (synchronously). * * @return {boolean} Indicates if directory has been created or not. */ export function createExtensionDirectoryIfNeededSync(): boolean { const DIR = getExtensionDirInHome(); if (!fsExtra.existsSync(DIR)) { fsExtra.mkdirsSync(DIR); return true; } return false; }
static getLogDirectory() { if (Command.APP_NAME === null) { throw Error('No app name set'); } try { fs.statSync(paths.log); } catch (e) { fs.mkdirsSync(paths.log); } return paths.log; }