本文整理汇总了TypeScript中@cmt/pr.fs.rename方法的典型用法代码示例。如果您正苦于以下问题:TypeScript fs.rename方法的具体用法?TypeScript fs.rename怎么用?TypeScript fs.rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@cmt/pr.fs
的用法示例。
在下文中一共展示了fs.rename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Replace default variant', async () => {
const variantFile = path.join(testEnv.projectFolder.location, '.vscode', 'cmake-variants.json');
const variantFileBackup = path.join(testEnv.projectFolder.location, '.vscode', 'cmake-variants.json.backup');
await fs.rename(variantFile, variantFileBackup);
expect(await fs.exists(variantFile)).to.be.false;
// Set fake settings
testEnv.config.updatePartial({
defaultVariants: {
buildType: {
default: 'debug-label',
choices: {
'debug-label': {short: 'debug-label short', buildType: 'Debug'},
'not-debug': {short: 'not-debug short', buildType: 'Release'}
}
},
otherVariant: {
default: 'option1',
choices: {
option1: {short: 'option1 short', env: {TEST_VARIANT_ENV: '0xCAFE'}},
option2: {short: 'option2 short'}
}
}
}
});
try {
// Configure
expect(await cmt.configure()).to.be.eq(0, '[variantEnv] configure failed');
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'expected cache not present');
const cache = await CMakeCache.fromPath(await cmt.cachePath);
const cacheEntry_ = cache.get('variantEnv');
expect(cacheEntry_).to.not.be.eq(null, '[variantEnv] Cache entry was not present');
const cacheEntry = cacheEntry_!;
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[variantEnv] unexpected cache entry type');
expect(cacheEntry.key).to.eq('variantEnv', '[variantEnv] unexpected cache entry key name');
expect(typeof cacheEntry.value).to.eq('string', '[variantEnv] unexpected cache entry value type');
expect(cacheEntry.as<string>()).to.eq('0xCAFE', '[variantEnv] incorrect environment variable');
} finally {
// Restore the vairants file to before the test
await fs.rename(variantFileBackup, variantFile);
}
}).timeout(100000);
示例2: teardown
teardown(async function(this: Mocha.IBeforeAndAfterContext) {
const variantFileBackup = path.join(testEnv.projectFolder.location, '.vscode', 'cmake-variants.json');
if (await fs.exists(variantFileBackup)) {
const variantFile = path.join(testEnv.projectFolder.location, '.vscode', 'cmake-variants.json');
await fs.rename(variantFileBackup, variantFile);
}
this.timeout(30000);
await cmt.asyncDispose();
testEnv.teardown();
});