當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。