本文整理汇总了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
);
}
}
},