Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async reset() {
this.logWithMetadata(['info', 'optimize:watch_cache'], 'The optimizer watch cache will reset');
// start by deleting the state file to lower the
// amount of time that another process might be able to
// successfully read it once we decide to delete it
await del(this.statePath, { force: true });
// delete everything in optimize/.cache directory
await del(await globby([normalizePosixPath(this.cachePath)], { dot: true }));
// delete some empty folder that could be left
// from the previous cache path reset action
await deleteEmpty(this.cachePath);
// delete dlls
await del(this.dllsPath);
// re-write new cache state file
await this.write();
this.logWithMetadata(['info', 'optimize:watch_cache'], 'The optimizer watch cache has reset');
}
async function main() {
const inputFiles = program.args.length == 0 ? DEFAULT_FILES : program.args;
const paths = await globby([...inputFiles, ...IGNORED_FILES]);
paths.forEach(filePath => {
// $FlowFixMe: flow doesn't accept dynamic require
require(path.resolve(process.cwd(), filePath));
});
// Get all suites to run
const input = getBenchmark();
const previous = program.compare
? await loadResult(path.resolve(process.cwd(), program.compare))
: null;
const reporter = new BackgroundReporter();
// Setup options for scenarios
const options = {
export async function find(fileGlob: string, options?: FindOptions): Promise {
const findOptions: Required = {
cwd: '.',
safeGuard: true,
...options,
};
const matches = await globby(`**/${fileGlob}`, {cwd: findOptions.cwd, followSymbolicLinks: false, onlyFiles: true});
if (matches.length > 0) {
const file = path.resolve(matches[0]);
return {fileName: path.basename(file), filePath: file};
}
if (findOptions.safeGuard) {
throw new Error(`Could not find "${fileGlob}".`);
}
return null;
}
async function searchGitFile (dir) {
let deps = 10
while (!(await globby('.git', { cwd: dir })).length && deps > 0) {
dir = path.resolve(dir, '..')
--deps
}
if (!(await globby('.git', { cwd: dir })).length) {
throw new Error('Could not find .git file')
} else {
return path.resolve(dir)
}
}
if (!Object.keys(config).length) {
const DEFAULT_CONFIG_PATH = 'build/config/compose-biz-apps.js'
config = await globby(DEFAULT_CONFIG_PATH)
if (config && config.length) {
config = config[0]
config = require(join(cwd, config))
} else {
warn(`${DEFAULT_CONFIG_PATH} is not exist, default will compose all biz-apps under src`)
}
}
let options = config.options || {}
let bizapps = config['biz-apps'] || []
if (!bizapps.length) {
bizapps = await globby('*', { cwd: join(cwd, 'src/biz-apps/') })
}
log(`composing biz-apps: ${bizapps.join(', ')}`)
options = { ...defaultOptions, ...options }
await composeApps(resolve(cwd, './src'), options, ...bizapps)
}
async function getAssets(_skpmConfig) {
if (!_skpmConfig.assets || !_skpmConfig.assets.length) {
return []
}
const assets = await globby(_skpmConfig.assets, { dot: true })
return assets
}
resolveFiles(dependencies, true)
models.push({
file: model.file,
root: model.root,
is_dependency: model.is_dependency,
dependencies: model.settings.dependencies,
inputs: model.settings.inputs,
dependants: [],
status: new RunStatus(),
})
}
}
}
this.api.settings.models = await globby(this.api.resolveGlobs(globs), {
cwd: this.api.settings.root,
})
resolveFiles(this.api.settings.models)
models = resolveDependenciesOrder(models)
models = resolveDependants(models)
return models
}
const listPaths = () => globby('packages/*');
const loadCommonCss = async (story: StoryT = mainStory): Promise => {
story.info('extractor', 'Extracting common CSS...');
const cssPaths = await globby(_config.cssPatterns);
_commonCss = cssPaths.map(cssPath => {
story.info('extractor', `Processing ${chalk.cyan.bold(cssPath)}...`);
return fs.readFileSync(cssPath, 'utf8');
});
};