本文整理匯總了TypeScript中tempy.directory函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript directory函數的具體用法?TypeScript directory怎麽用?TypeScript directory使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了directory函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("should not throw if there's no package.json", async (): Promise<void> => {
const dir = tempy.directory()
await index(
['', getScriptPath(dir), 'pre-push'],
(): Promise<string> => Promise.resolve('foo')
)
})
示例2: it
it('should run working command and return 0 status', (): void => {
const dir = tempy.directory()
const filename = path.join(dir, 'package.json')
fs.writeFileSync(
filename,
JSON.stringify({
scripts: {
commitmsg: 'echo $GIT_PARAMS GIT_PARAMS HUSKY_GIT_PARAMS',
precommit: 'npm test'
}
}),
'utf-8'
)
index(dir)
expect(JSON.parse(fs.readFileSync(filename, 'utf-8'))).toEqual({
husky: {
hooks: {
'commit-msg':
'echo $HUSKY_GIT_PARAMS HUSKY_GIT_PARAMS HUSKY_GIT_PARAMS',
'pre-commit': 'npm test'
}
},
scripts: {}
})
})
示例3: it
it('should return default conf', (): void => {
const tempDir = tempy.directory()
fs.writeFileSync(
path.join(tempDir, 'package.json'),
JSON.stringify(testConf)
)
expect(getConf(tempDir)).toEqual({ skipCI: true, foo: 'bar' })
})
示例4: beforeEach
beforeEach(async () => {
tmpDir = tempy.directory();
buildRoot = tempy.directory();
const fixturesPath = resolve(__dirname, '__fixtures__');
// Copy all the test fixtures into a tmp dir, as we will be mutating them
await copy(['**/*'], tmpDir, {
cwd: fixturesPath,
dot: true,
nodir: true,
parents: true,
});
const projects = await getProjects(tmpDir, ['.', './packages/*']);
for (const project of projects.values()) {
// This will both install dependencies and generate `yarn.lock` files
await project.installDependencies({
extraArgs: ['--silent', '--no-progress'],
});
}
}, timeout);
示例5: async
async () => {
const tmpDir = tempy.directory();
const buildRoot = tempy.directory();
const fixturesPath = resolve(__dirname, '__fixtures__');
// Copy all the test fixtures into a tmp dir, as we will be mutating them
await copy(['**/*'], tmpDir, {
cwd: fixturesPath,
dot: true,
nodir: true,
parents: true,
});
const projects = await getProjects(tmpDir, ['.', './packages/*']);
for (const project of projects.values()) {
// This will both install dependencies and generate `yarn.lock` files
await project.installDependencies({
extraArgs: ['--silent', '--no-progress'],
});
}
await buildProductionProjects({ kibanaRoot: tmpDir, buildRoot });
const files = await globby(['**/*', '!**/node_modules/**'], {
cwd: buildRoot,
});
expect(files.sort()).toMatchSnapshot();
for (const file of files) {
if (file.endsWith('package.json')) {
expect(await readPackageJson(join(buildRoot, file))).toMatchSnapshot(
file
);
}
}
},