本文整理匯總了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);
}