当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript temp-sandbox.createFileSync函数代码示例

本文整理汇总了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';`,
    );
}
开发者ID:chrisblossom,项目名称:clean-webpack-plugin,代码行数:8,代码来源:clean-webpack-plugin.test.ts

示例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([]);
    });
开发者ID:chrisblossom,项目名称:clean-webpack-plugin,代码行数:34,代码来源:clean-webpack-plugin.test.ts

示例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);
}
开发者ID:chrisblossom,项目名称:clean-webpack-plugin,代码行数:23,代码来源:clean-webpack-plugin.test.ts


注:本文中的temp-sandbox.createFileSync函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。