本文整理汇总了TypeScript中glob类的典型用法代码示例。如果您正苦于以下问题:TypeScript glob类的具体用法?TypeScript glob怎么用?TypeScript glob使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了glob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: glob
env.app.dirs.subscribers.forEach((pattern) => {
glob(pattern, (err: any, files: Array<string>) => {
for (const file of files) {
require(file);
}
});
});
示例2: task
task('e2e.bundle', (done) => {
let includeGlob = `${DIST_E2E_ROOT}/components/*/test/*/entry.js`;
let folderInfo = getFolderInfo();
if (folderInfo.componentName && folderInfo.componentTest) {
includeGlob = `${DIST_E2E_ROOT}/components/${folderInfo.componentName}/test/${folderInfo.componentTest}/entry.js`;
}
glob(includeGlob, {}, function(er, files) {
var directories = files.map(function(file) {
return dirname(file);
});
let indexFileContents = directories.map(function(dir) {
let testName = dir.replace(`${DIST_E2E_ROOT}/components/`, '');
let fileName = dir.replace(`${PROJECT_ROOT}`, '');
return `<p><a href="${fileName}/index.html">${testName}</a></p>`;
}, []);
writeFileSync(`${DIST_E2E_ROOT}/index.html`,
'<!DOCTYPE html><html lang="en"><head></head><body style="width: 500px; margin: 100px auto">\n' +
indexFileContents.join('\n') +
'</center></body></html>'
);
createBundles(files).then(() => {
done();
}).catch(err => {
done(err);
});
});
});
示例3: constructor
constructor() {
this._basename = basename(module.filename).toLowerCase();
let db = DbConfig;
// let dbConfig = configs.getDatabaseConfig();
// if (dbConfig.logging) {
// dbConfig.logging = logger.info;
// }
//(SequelizeStatic as any).cls = cls.createNamespace("sequelize-transaction");
this._sequelize = new SequelizeStatic(db.Database, db.UserName, db.Password, db.Options);
this._models = ({} as any);
let modelPattern = join(__dirname, '../Modules', '/**/*.Model.js');
console.log(modelPattern);
glob(modelPattern, (err: Error, files: string[]): void => {
if (err) {
console.error(err);
}
console.log(files);
files.forEach((file: string) => {
let model = this._sequelize.import(file);
(this._models as any)[(model as any).name] = model;
});
Object.keys(this._models)
.forEach((modelName: string) => {
if (typeof (this._models as any)[modelName].associate === 'function') {
(this._models as any)[modelName].associate(this._models);
}
});
});
//this._sequelize.sync(); //TODO: Creating Table - RND required.
}
示例4: Promise
return new Promise((resolve, reject) => {
glob(pattern, options, function (err, files) {
if (err) {
return reject(err);
}
return resolve(files);
});
});
示例5: Promise
return new Promise((resolve, reject) => {
glob(titleData.finalGlob, { silent: true, dot: true, cwd: directory, cache: cache || {} }, (err, files) => {
if (err)
reject(err);
else
resolve(files);
});
}).then((files: string[]) => {
示例6: Promise
return new Promise((resolve, reject) => {
glob(`${paths.sourceRoot}tasks/**/index.ts`, (err, matches) => {
if(err){
reject(err);
}
resolve(matches);
});
})
示例7: globMod
return new Promise<string[]>((resolve: (result: string[]) => void, reject: (error: any) => void) => {
globMod(pattern, opts || {}, (err: Error, files: string[]) => {
if (err) {
reject(err);
} else {
resolve(files);
}
});
});
示例8: Promise
return new Promise((resolve, reject) => {
glob('**/*.ts', { ignore: blacklist }, (error, matches) => {
if (error) {
reject(error);
} else {
resolve(matches);
}
});
});
示例9: Promise
return new Promise((resolve, reject) => {
glob(pattern, (err, matches) => {
if(err){
reject(err);
return;
}
resolve(matches);
})
});
示例10: Promise
return new Promise((resolve, reject) => {
const mainGlob = join(DEMOS_SRC_ROOT, '**', 'main.ts');
glob(mainGlob, (err: Error, matches: string[]) => {
if (err) {
return reject(err);
}
resolve(matches);
});
});
示例11: Promise
return new Promise((resolve, reject) => {
const mainGlob = join(SRC_COMPONENTS_ROOT, '*', 'test', '*', 'e2e.ts');
glob(mainGlob, (err: Error, matches: string[]) => {
if (err) {
return reject(err);
}
resolve(matches);
});
});
示例12: Promise
return new Promise((resolve, reject) => {
glob(path, {
cwd: cwd ? cwd: process.cwd()
}, (err, paths) => {
if (err) {
return reject(err);
}
return resolve(paths);
})
});
示例13: Promise
return new Promise((resolve, reject) => {
const options = exclude ? { ignore: exclude } : {};
glob(globPath, options, (error, matches) => {
if (error) {
return reject(error);
}
resolve(matches);
});
});
示例14: glob
async.reduce( args.entry_points, new Array<{name:string,signature:string}>(), ( cns, entry_point, cb_reduce ) => {
glob( entry_point, { cwd: args.launch_dir }, ( err, matches ) => {
if ( err ) { this.error( err.toString() ); return cb_reduce( new Error, null ); }
async.map( matches, ( x, cb_map ) => {
const my_cb_map = ( err: boolean, val ) => { cb_map( err ? new Error : null, val ) };
this.get_filtered_target( path.resolve( args.launch_dir, x ), args.launch_dir, my_cb_map );
}, ( err, lst: Array<{name:string,signature:string}> ) => {
cb_reduce( null, cns.concat( lst ) );
} );
} );
}, ( err, cns ) => {
示例15: glob
const run = (): void => {
glob('./src/app/**/*.vue', (err: any, files: string[]) => {
const basePath: string = path.resolve(process.cwd());
const packageJSON: any = JSON.parse(fs.readFileSync(path.join(basePath, 'package.json')).toString());
const supportedLocales: string[] = packageJSON.config['supported-locales'];
const defaultLocale: string = packageJSON.config['default-locale'];
let translations: any = {};
/**
* go through all *.vue files end extract the translation object $t('foo') -> {id: 'foo'}
*/
files.forEach((file: string) => {
const content = fs.readFileSync(file).toString();
const matches: string[] = getTranslationsFromString(content);
if (matches) {
translations = { ...translations, ...getTranslationObject(matches) };
}
});
/**
* analyze and write languages files
*/
supportedLocales.forEach((locale: string) => {
const i18nFilePath: string = path.join(basePath, 'i18n', `${locale}.json`);
const i18nFileContent: string = fs.existsSync(i18nFilePath) ? fs.readFileSync(i18nFilePath).toString() : null;
const i18nFileObject: any = i18nFileContent ? JSON.parse(i18nFileContent) : {};
(Object as any).keys(i18nFileObject).forEach((key: string) => {
i18nFileObject[key] = i18nFileObject[key].replace(/\n/g, '\\n').replace(/"/g, '\\"');
});
const newI18nObject: any = locale === defaultLocale
? (Object as any).assign({}, i18nFileObject, translations)
: (Object as any).assign({}, translations, i18nFileObject);
/**
* sort entries
*/
const sortedKeys: string[] = (Object as any).keys(newI18nObject).sort();
const sortedEntries: string[] = sortedKeys.map((key: string) => {
return `"${key}": "${newI18nObject[key]}"`;
});
fs.writeFileSync(path.join(basePath, 'i18n', `${locale}.json`), `{\n ${sortedEntries.join(',\n ')}\n}\n`);
console.info(`wrote i18n/${locale}.json`);
});
console.info('i18n extraction finished');
});
};