本文整理匯總了TypeScript中pkg-dir.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Promise
it('bundleable by webpack with no errors', async function() {
this.timeout(50000);
const memoryFS = new MemoryFS();
const rootPath = await pkgDir(__dirname);
const compiler = webpack({
mode: 'development',
entry: {
main: path.join(rootPath!, 'dist', 'src', 'lib', 'service.js')
},
node: {
path: 'empty', // users should provide alias to path-webpack
net: 'empty',
fs: 'empty',
module: 'empty'
}
});
compiler.outputFileSystem = memoryFS;
await new Promise((res, rej) =>
compiler.run((err, stats) => {
if (err || stats.hasErrors()) {
rej(err || new Error(stats.toString()));
} else {
res();
}
})
);
});
示例2: install
public static async install (
puppetModule : string,
puppetVersion = 'latest',
): Promise<void> {
log.info('PuppetManager', 'install(%s@%s) please wait ...', puppetModule, puppetVersion)
await npm.install(
`${puppetModule}@${puppetVersion}`,
{
cwd : await pkgDir(__dirname),
output : true,
save : false,
},
)
log.info('PuppetManager', 'install(%s@%s) done', puppetModule, puppetVersion)
}
示例3: run
async function run() {
const rootPath = await pkgDir()
const isInPackage = rootPath !== null
if (isInPackage) {
const scriptsPath = join(rootPath, 'node_modules', '.bin', 'tux-scripts')
const insideTuxProject = await fs.pathExists(scriptsPath)
if (insideTuxProject) {
// tslint:disable-next-line:no-console
console.log(`Inside ${chalk.cyan('tux')} project.`)
require(scriptsPath)
return
}
}
// tslint:disable-next-line:no-console
console.log(`Not inside ${chalk.cyan('tux')} project.`)
require('./new')
}
示例4: installAll
public static async installAll (): Promise<void> {
log.info('PuppetManager', 'installAll() please wait ...')
const moduleList: string[] = []
for (const puppetModuleName of Object.keys(PUPPET_DEPENDENCIES)) {
const version = PUPPET_DEPENDENCIES[puppetModuleName as any as PuppetModuleName]
if (version !== '0.0.0') {
moduleList.push(`${puppetModuleName}@${version}`)
}
}
await npm.install(
moduleList,
{
cwd : await pkgDir(__dirname),
output : true,
save : false,
},
)
}
示例5: suiteSetup
suiteSetup(async () => {
rootDir = await pkgDir(__dirname);
});