本文整理汇总了TypeScript中temp-sandbox.createFileSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createFileSync函数的具体用法?TypeScript createFileSync怎么用?TypeScript createFileSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createFileSync函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createStaticFiles
function createStaticFiles() {
sandbox.createFileSync('dist/.hidden.file', '.hidden.file');
sandbox.createFileSync('dist/static2.txt', 'static2.txt');
sandbox.createFileSync(
'dist/static1.js',
`'use strict';\n\nmodule.exports = 'static1.js';`,
);
}
示例2: test
test('removes files outside of process.cwd() with dangerouslyAllowCleanPatternsOutsideProject: true', async () => {
process.chdir(cwd);
createSrcBundle(1);
const outsideDistPath = 'build';
sandbox.createFileSync('build/outside-file.js', '// outside-file.js');
const initialOutsideFiles = sandbox.getFileListSync(outsideDistPath);
expect(initialOutsideFiles).toEqual(['outside-file.js']);
const cleanWebpackPlugin = new CleanWebpackPlugin({
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: false,
cleanAfterEveryBuildPatterns: [
path.join(sandbox.dir, 'build/**/*'),
],
});
expect(consoleSpy.mock.calls).toEqual([]);
const compiler = webpack({
entry: entryFileFull,
output: {
path: outputPathFull,
filename: 'bundle.js',
chunkFilename: '[name].bundle.js',
},
plugins: [cleanWebpackPlugin],
});
await compiler.run();
expect(sandbox.getFileListSync(outsideDistPath)).toEqual([]);
});
示例3: createSrcBundle
function createSrcBundle(numberOfBundles = 1) {
sandbox.deleteSync(sourcePath);
let entryFileContents = `'use strict';\n\n`;
let count = 1;
while (count < numberOfBundles) {
const filename = `${count}.js`;
entryFileContents = `${entryFileContents}
require.ensure([], function(require){ require('./${filename}')}, '${count}');`;
sandbox.createFileSync(
`src/${filename}`,
// eslint-disable-next-line no-useless-concat
`'use strict';\n\n` + `module.exports = '${filename}';`,
);
count += 1;
}
sandbox.createFileSync(entryFile, entryFileContents);
}