Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const tmpPath = path.join(tmpPathRoot, tmpPathName);
options.cwd = tmpPath;
if (options.force === undefined) {
options.force = true;
}
jest.setTimeout(10000);
await deleteDir(tmpPath);
try {
await fs.mkdir(tmpPathRoot);
} catch (err) {}
await fs.mkdir(tmpPath);
await api(options);
const files = (await fs.readdir(tmpPath))
.filter((dirName: string) => !fs.statSync(path.join(tmpPath, dirName)).isDirectory())
.filter(removeIgnoredFiles)
.sort();
let i = 0;
for (i = 0; i < files.length; i += 1) {
const fileData = await fs.readFile(path.join(tmpPath, files[i]), 'utf8');
const tree = renderer.create().toJSON();
expect(tree).toMatchSnapshot();
}
// normalize pathes to look the same on windows, linux and mac
// expect.addSnapshotSerializer({
// test: (val) => typeof val === 'string',
// print(val) {
// return `${val.replace(/\\/g, '/')}`;
// Check that source is set to record only
t.true(await client.isExisting('.sl-vue-tree-sidebar .source-selector-action.icon-studio'));
// Start recording
await client.click('.record-button');
await sleep(2000);
// Ensure recording indicator is active
t.true(await client.isExisting('.record-button.active'));
// Stop recording
await client.click('.record-button');
await client.waitForVisible('.record-button:not(.active)', 60000);
// Check that file exists
const files = await readdir(tmpDir);
t.is(files.length, 1);
});
async function main(){
const folderToScan = './recordings';
fs.readdir(folderToScan, (err, files) => {
// console.log(files);
if(!files){
console.log('no files in directory')
return
}
files.forEach(async (file) => {
// console.log(file);
const split = file.split('&');
const username = split[0];
const filename = split[1];
function writeFiles (type, distPath, data) {
let tplPath = path.join(__dirname, type)
fs.readdir(tplPath, 'utf8', (err, files) => {
if (err) {
console.log(colors.red(err))
return false
}
files.forEach((filename) => {
let content = compile(path.join(tplPath, filename), data)
let distFileName = data.name + '.' + filename.split('.')[1]
let filePath = path.join(distPath, distFileName)
console.log(colors.green('write file: '))
console.log(colors.underline(filePath))
fs.writeFileSync(filePath, content, 'utf8')
})
.then(() => { //check to make sure there arent two config files (both a json and a js file, if there are both, use the json file)
return fs.readdir(path.join(this.config.app_root, 'content/config'));
})
.then(configFiles => {
async getFilesPaths(path) {
const type = await fs.stat(path);
if (type.isFile()) return path;
const paths = await fs.readdir(path);
const filesPromises = paths.map(
async p => await this.getFilesPaths(`${path}/${p}`),
);
const files = await Promise.all(filesPromises);
const flattenFiles = files.reduce(
(arr, x) => (Array.isArray(x) ? [...arr, ...x] : [...arr, x]),
[],
);
return flattenFiles;
}
return queue.then(() => {
return fs.readdir(directoryPath).then(items => {
directories.push({
items,
type
})
})
})
}, Promise.resolve())
async.each(plugindata.pluginTypes, function iterator(pluginType, doneMapIterator) {
var srcDir = path.join(COURSE_ROOT_FOLDER, Constants.Folders.Source, pluginType.folder);
if (!fs.existsSync(srcDir)) {
logger.log('info', 'No plugins found.');
return doneMapIterator();
}
fs.readdir(srcDir, function (err, files) {
if (err) {
return doneMapIterator(err);
}
files.map(function (file) {
return path.join(srcDir, file);
}).filter(function (file) {
return fs.statSync(file).isDirectory();
}).forEach(function (file) {
var data = _.extend(_.clone(pluginType), { location: file });
plugindata.pluginIncludes.push(data);
});
doneMapIterator();
});
}, function(err) {
if(err) {
return new Promise((resolve, reject) => {
try {
const standardModelsDir = (container.name) ?
(container.type === 'local') ?
`${this.config.app_root}/content/container/${container.name}/config/databases/standard/models` :
`${this.config.app_root}/node_modules/${container.name}/config/databases/standard/models` :
`${this.config.app_root}/node_modules/${extension.name}/config/databases/standard/models`;
const modelFilesMap = getModelFilesMap.bind(standardModelsDir);
fs.readdir(standardModelsDir)
.then(modelFiles => {
const modelFilesFullPath = modelFiles.map(file => getModelFilesMap(standardModelsDir, file));
this.resources.standard_models.push(...modelFilesFullPath);
resolve(true);
}).catch(e => {
resolve('does not have standard models');
});
} catch (e) {
reject(e);
}
});
}