本文整理汇总了TypeScript中glob.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript glob.default方法的具体用法?TypeScript glob.default怎么用?TypeScript glob.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glob
的用法示例。
在下文中一共展示了glob.default方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dirname
task('e2e.bundleProd', (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);
});
});
});
示例2: run
export function run(testsRoot: string, clb: (error, failures?: number) => void): void {
// Enable source map support
require('source-map-support').install();
// Glob test files
glob('**/**.test.js', { cwd: testsRoot }, (error, files) => {
if (error) {
return clb(error);
}
try {
// Fill into Mocha
files.forEach(f => mocha.addFile(paths.join(testsRoot, f)));
// Run the tests
let failures = 0;
mocha.run()
.on('fail', function(test, err) {
failures++;
})
.on('end', function() {
clb(null, failures);
});
} catch (error) {
return clb(error);
}
});
}
示例3: Promise
return new Promise((resolve, reject) => {
glob('**/tsconfig.json', { ignore: '**/node_modules/**' }, (error: Error | null, tsConfigFiles: string[]) => {
if (error) {
reject(error);
}
tsConfigFiles.forEach(file => {
let args = ['-p', file];
let taskFunction = (callback: TaskFunctionCallback) => {
let task = taskRunner.runTask(`./node_modules/.bin/tsc`, args, {
name: `tsc -p ${file}`,
logger,
handleOutput
});
runningTasks.push(task);
task.result.then(() => {
runningTasks.splice(runningTasks.indexOf(task), 1);
}).then(callback).catch(reject);
};
taskFunctions.push(taskFunction);
});
let limit = 2;
parallelLimit(taskFunctions, limit, resolve);
});
});
示例4: buildStyles
export function buildStyles(options: StylesConfig): void {
const {src, out} = options;
const scssFiles = path.join(src, '!(+(_))*.scss');
const iconsPromise = copyOcticons(out);
glob(scssFiles, (err, scss) => {
if (err) {
return console.log(`failed to compile scss in ${src}: ${err}`);
}
resourceChecksum.load(src).then(checksums => {
const scssPromise = Promise.all(scss.map(f => compileScss(f, out, checksums)));
Promise.all([iconsPromise, scssPromise])
.then(() => {
return removeCSSWithNoSCSS(scss, out, checksums);
})
.then(() => {
resourceChecksum.save(checksums, src);
})
.catch(buildError => {
console.error(buildError);
});
});
});
}
示例5: glob
return new Promise<string[]>((resolve, reject) => {
glob(
g,
(err: Error | null, files: string[]) =>
err ? reject(err) : resolve(files)
);
});
示例6: Promise
return new Promise((resolve, reject) => {
const pkg = JSON.parse(readFileSync(`${folder}package.json`, "utf8"));
glob(`${folder}types/**/*.d.ts`, {}, function (err: any, files: any) {
if (err) throw err;
let typePath = `${folder}types/index.node.d.ts`;
if (!existsSync(typePath)) {
typePath = `${folder}types/index.d.ts`;
}
if (existsSync(typePath)) {
const externals = calcExternals(typePath, `tmp/${pkg.name}`);
externals.forEach(external => {
if (!pkg.dependencies || (!pkg.dependencies[external] && !pkg.dependencies["@types/" + external])) {
expect(false, `${pkg.name}:${folder} missing dependency: ${external}`).to.be.true;
}
});
for (const key in pkg.dependencies) {
const deps = key.indexOf("@types/") === 0 ? key.substr(7) : key;
if (NODEJS_DEPENDENCY_EXCEPTIONS.indexOf(deps) < 0 && key.indexOf("@hpcc-js") < 0 && externals.indexOf(deps) < 0) {
expect(false, `${pkg.name}:${folder} extraneous dependency: ${deps}`).to.be.true;
}
}
}
resolve();
});
});
示例7: makeZip
function makeZip(target: string): void {
const zip = new JSZip();
glob(`${target}/**/*.*`, {cwd: baseDir}, (_error, matches) => {
Promise.all(matches.map(itemPath => new Promise((resolve, reject) => {
const itemPathFs = path.normalize(itemPath);
const itemPathFsWithBase = path.join(baseDir, itemPathFs);
fs.readFile(itemPathFsWithBase, (err, itemData) => {
console.log(`including ${itemPath}`);
if (err) {
reject(err);
return;
}
zip.file(itemPathFs, itemData);
resolve();
});
})))
.then(() => new Promise((resolve, reject) => {
const dest = path.join(baseDir, `${target}.zip`);
zip
.generateAsync({ type: "nodebuffer" })
.then(content => {
fs.writeFile(dest, content, err => {
if (err) {
reject(err);
return;
}
resolve(dest);
});
})
.catch(err => reject(err));
}))
.then(dest => console.log(`${dest} was written.`))
.catch(e => console.error(e));
});
}
示例8: 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.
}
示例9: return
return (req: express.Request, res: express.Response) => {
glob(path.join(dir, '**/*.ts'), (err: any, fullPaths: string[]) => {
if (err) console.log(err);
let relativePaths = fullPaths.map(f => path.relative(dir, f));
res.json(JSON.stringify(relativePaths));
});
}