本文整理匯總了TypeScript中read-pkg.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: execa
skipOnWindows(plugin, async () => {
const cwd = path.join(__dirname, '../../tmp/plugin', plugin)
await fs.remove(cwd)
const pkg = await readPkg(path.join(__dirname, '../../node_modules', plugin, 'package.json'))
await execa('git', ['clone', pkg.repository.url.split('+')[1], cwd])
const opts = {cwd, stdio: [0, 1, 2]}
await execa('git', ['checkout', `v${pkg.version}`], opts)
await execa('yarn', [], opts)
await execa('yarn', ['test'], opts)
})
示例2: readPkg
const getTextlintDependencyNames = (dir: string): Promise<Array<string>> => {
return readPkg(dir)
.then((pkg: any) => {
const dependencies = pkg.dependencies || {};
const devDependencies = pkg.devDependencies || {};
const mergedDependencies = ObjectAssign({}, dependencies, devDependencies);
const pkgNames = Object.keys(mergedDependencies);
return pkgNames.filter(pkgName => {
const ruleOrFilter =
pkgName.indexOf(TextlintPackageNamePrefix.filterRule) !== -1 ||
pkgName.indexOf(TextlintPackageNamePrefix.rule) !== -1;
if (pkgName === "textlint-rule-helper") {
return false;
}
return ruleOrFilter;
});
})
.catch(() => {
return [];
});
};
示例3: readPackageJson
export function readPackageJson(dir: string) {
return readPkg(dir, { normalize: false });
}