write(data) { fs.ensureDirSync(path.dirname(this.filePath)); fs.writeFileSync(this.filePath, JSON.stringify(data)); }
beforeEach(() => { fs.emptyDirSync(TEST_DIR) DIRS = dirnames.map(dir => path.join(TEST_DIR, dir)) FILES = filenames.map(f => path.join(TEST_DIR, f)) DIRS.forEach(dir => fs.ensureDirSync(dir)) FILES.forEach(f => fs.ensureFileSync(f)) })
test('should create nested path', () => { fs.ensureDirSync.mockImplementation((p) => { }); const r = mkdirSync('fakePath/subDir'); expect(r).toBeUndefined(); });
beforeAll(() => { fs.ensureDirSync(tmpDir); fs.copySync(path.resolve(fixturesDir, 'testapp'), path.resolve(tmpDir, 'testapp')); api = new Api(null, testProjectDir); });
constructor(options) { this.size = options.size; this.cacheDir = options.cacheDir || path.join(os.homedir(), ".cache", "thumbsupply", this.size.name); fs.ensureDirSync(this.cacheDir); }
publishAllContainers(outputPath) { fs.ensureDirSync(outputPath); const containers = this.render.getContainers(); containers.map((item) => { const componentFolder = path.join(outputPath, item); fs.ensureDirSync(componentFolder); const componentFile = path.join(componentFolder, `index.html`); const component = this.render.renderServerComponent(item); _writeFile(componentFile, component); }) }
// :: string -> void const ensureParentDirectoryExists = filePath => { const dir = path.dirname(filePath) fs.ensureDirSync(dir) }
async function initialize() { fs.ensureDirSync(`${DATA_ROOT}/imageCache`); fs.ensureFileSync(`${DATA_ROOT}/series-data.json`); fs.ensureFileSync(`${DATA_ROOT}/config.json`); seriesDataStorage = low(new FileSync(`${DATA_ROOT}/series-data.json`)); seriesDataStorage.defaults({}).write(); }
/** * Create a dataDir * @private */ _createDataDirSync() { fse.ensureDirSync(this._options.dataDir) }
test('should throw error', () => { fs.ensureDirSync.mockImplementation((p) => { throw { code: 'FAKE_ERROR' } }); try { mkdirSync('fakePath'); fail(); } catch (e) { expect(e.code).toEqual('FAKE_ERROR'); } });
async function createLoggerFile(dirPath) { await installLogger(dirPath); await fs.ensureDirSync(dirPath); await fs.copySync(`${templatesPath}/starterLogger.txt`, `${dirPath}/libs/logger.js`); }
beforeAll(() => { fs.ensureDirSync(tmpDir); fs.copySync(path.resolve(fixturesDir, 'testapp'), testProjectDir); apiEvents = Api.__get__('selfEvents'); apiEvents.addListener('verbose', (data) => { }); });
test('shouldn\'t throw error if error is EEXIST', () => { fs.ensureDirSync.mockImplementation((p) => { throw { code: 'EEXIST' } }); try { mkdirSync('fakePath'); } catch (e) { fail(); } });
test('should create path', () => { fs.ensureDirSync.mockImplementation((p) => { }); const r = mkdirSync('fakePath'); expect(r).toBeUndefined(); });
beforeAll(() => { fs.ensureDirSync(tmpDir); fs.copySync(path.resolve(fixturesDir, 'testapp'), path.resolve(tmpDir, 'testapp')); api = new Api(null, testProjectDir); });