當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs-extra.outputFileSync函數代碼示例

本文整理匯總了TypeScript中fs-extra.outputFileSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript outputFileSync函數的具體用法?TypeScript outputFileSync怎麽用?TypeScript outputFileSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了outputFileSync函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: createNpmBinScript

export function createNpmBinScript(execName: string): void {
    let fileName: string;
    let script: string;

    if (process.platform === 'win32') {
        fileName = `${execName}.cmd`;
        script = `.\\.ruff\\bin\\${execName}.exe %*`;
    } else {
        fileName = execName;
        script = `\
#!/bin/sh
./.ruff/bin/${execName} "$@"`;
    }

    let filePath = Path.resolve('node_modules/.bin', fileName);
    FS.outputFileSync(filePath, script);

    if (process.platform !== 'win32') {
        FS.chmodSync(filePath, 0o744);
    }
}
開發者ID:vilic,項目名稱:rvm,代碼行數:21,代碼來源:index.ts

示例2: readdirSync

export = () => {
  const modules: string[] = readdirSync(Config.APP_SRC);
  let modulesContent = '/* tslint:disable */\n';
  const classes = [];
  for (const module of modules) {
    const moduleFilePath = `${Config.APP_SRC}/${module}/client/${_.kebabCase(module)}.module.ts`;
    if (existsSync(moduleFilePath)) {
      const {importPath, className} = parseFilePath(moduleFilePath, Config.APP_SRC);
      modulesContent += `import { ${className} } from '../${config.APP_SRC}${importPath}';\n`;
      classes.push(className);
    }
  }
  modulesContent = `${modulesContent}
export const PLUGIN_MODULES = [
  ${classes.join(',\n  ')}
];
`;
  const modulesFilesPath = join(config.GEN_FOLDER, 'modules.ts');
  let isSame = false;
  try {
    isSame = readFileSync(modulesFilesPath, 'utf-8') === modulesContent;
  } catch (ignored) {
  }
  if (!isSame) {
    outputFileSync(modulesFilesPath, modulesContent);
  }

  function pascalCase(string: string) {
    return _.upperFirst(_.camelCase(string));
  }

  function parseFilePath(file: string, componentsPath: string) {
    componentsPath = componentsPath.replace(/\\/g, '/');
    const importPath = file.replace(componentsPath, '').replace('.ts', '');
    const split = importPath.split('/');
    const className = pascalCase(split[split.length - 1].replace(/-/g, '.'));
    return {importPath, className};
  }
};
開發者ID:our-city-app,項目名稱:gae-plugin-framework,代碼行數:39,代碼來源:build.plugins.typescript.ts

示例3: test

  test('load yml with secret and env var in .env', async () => {
    const secret = 'this-is-a-long-secret'
    const yml = `\
service: jj
stage: dev
cluster: local

datamodel:
- datamodel.prisma

secret: \${env:MY_DOT_ENV_SECRET}

schema: schemas/database.graphql
    `
    const datamodel = `
type User @model {
  id: ID! @isUnique
  name: String!
  lol: Int
  what: String
}
`
    const { definition, env } = makeDefinition(yml, datamodel, {})
    const envPath = path.join(definition.definitionDir, '.env')

    fs.outputFileSync(
      envPath,
      `MY_DOT_ENV_SECRET=this-is-very-secret,and-comma,seperated`,
    )

    await env.load()

    try {
      await loadDefinition(yml, datamodel)
    } catch (e) {
      expect(e).toMatchSnapshot()
    }
  })
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:38,代碼來源:PrismaDefinition.test.ts

示例4: prepareTestUser

    function prepareTestUser() {

        // Set up basic logged in user data, this will be the active user
        const userData = {
            id: "api_testuser",
            token: "tokentoken",
            url: "https://api.sbgenomics.com",
            user: {username: "testuser",}
        };

        // This is the full path of the local profile file
        const localPath = dir.name + "/local";

        // Write basic user data to that profile file, so we don't start with a blank state
        const profileData = {
            credentials: [userData],
            activeCredentials: userData
        } as Partial<UserRepository>;

        fs.outputFileSync(localPath, JSON.stringify(profileData));

        return userData;
    }
開發者ID:hmenager,項目名稱:composer,代碼行數:23,代碼來源:data-repository.spec.ts

示例5: cloneOnConfigFetched

    function cloneOnConfigFetched(cfg: string) {
        var json: string = fs.readFileSync(cfg, 'utf8');

        let config: {
            defaultBranchName: string,
            refs: Object,
            commits: Object,
        } = JSON.parse(json);

        let nconfig = {
            defaultBranchName: config.defaultBranchName,
            currentBranchName: config.defaultBranchName,
            refs: config.refs,
            commits: config.commits,
            staged: []
        };

        var json = JSON.stringify(nconfig);
        fse.outputFileSync(cfg, json);

        let repo = new Common.Repo(process.cwd());
        repo.saveConfig();
        log.info(repo.name + ':', colors.yellow('' + repo.commits.length), 'commits');
    }
開發者ID:STALKER2010,項目名稱:jerk,代碼行數:24,代碼來源:cli.ts

示例6:

 return bootloader.serializeApplication().then(html =>  fse.outputFileSync(path.resolve(this.outputPath, this.indexPath), html, 'utf-8'));
開發者ID:QuinntyneBrown,項目名稱:issue-zero,代碼行數:1,代碼來源:broccoli-app-shell.ts

示例7:

 const preparations = () => {
   fse.outputFileSync("file.txt", test.content);
 };
開發者ID:szwacz,項目名稱:fs-jetpack,代碼行數:3,代碼來源:inspect.spec.ts

示例8:

 const preparations = () => {
   fse.outputFileSync("a/b/c.md", "abc");
 };
開發者ID:szwacz,項目名稱:fs-jetpack,代碼行數:3,代碼來源:find.spec.ts

示例9:

 const preparations = () => {
   fse.mkdirsSync("dir/empty");
   fse.outputFileSync("dir/empty.txt", "");
   fse.outputFileSync("dir/file.txt", "abc");
   fse.outputFileSync("dir/subdir/file.txt", "defg");
 };
開發者ID:szwacz,項目名稱:fs-jetpack,代碼行數:6,代碼來源:inspect_tree.spec.ts

示例10:

 const preparations = () => {
   fse.outputFileSync(filePath, "xyz");
   // Simulating remained file from interrupted previous write attempt.
   fse.outputFileSync(tempPath, "123");
 };
開發者ID:szwacz,項目名稱:fs-jetpack,代碼行數:5,代碼來源:write_atomic.spec.ts

示例11:

 const preparations = () => {
   fse.mkdirsSync("a/b/c");
   fse.outputFileSync("a/f.txt", "abc");
   fse.outputFileSync("a/b/f.txt", "123");
 };
開發者ID:szwacz,項目名稱:fs-jetpack,代碼行數:5,代碼來源:remove.spec.ts

示例12: writeFile

 private writeFile(buffer: Buffer, fileName: string, baseDir = Configuration.baseDir): string {
     const fullFilePath = path.join(baseDir, fileName);
     fs.outputFileSync(fullFilePath, buffer);
     return fullFilePath;
 }
開發者ID:KnowledgeExpert,項目名稱:allure-client,代碼行數:5,代碼來源:attachment.ts

示例13: exportKhaProject


//.........這裏部分代碼省略.........
	}
	
	let windowOptions = project.windowOptions ? project.windowOptions : defaultWindowOptions;
	exporter.setName(project.name);
	exporter.setWidthAndHeight(
		'width' in windowOptions ? windowOptions.width : defaultWindowOptions.width,
		'height' in windowOptions ? windowOptions.height : defaultWindowOptions.height
	);
	
	for (let source of project.sources) {
		exporter.addSourceDirectory(source);
	}
	for (let library of project.libraries) {
		exporter.addLibrary(library);
	}
	exporter.parameters = project.parameters;
	project.scriptdir = options.kha;
	project.addShaders('Sources/Shaders/**', {});
	project.addShaders('Kha/Sources/Shaders/**', {}); //**

	let assetConverter = new AssetConverter(exporter, options.target, project.assetMatchers);
	let assets = await assetConverter.run(options.watch);
	let shaderDir = path.join(options.to, exporter.sysdir() + '-resources');
	/*if (platform === Platform.Unity) {
		shaderDir = path.join(to, exporter.sysdir(), 'Assets', 'Shaders');
	}
	fs.ensureDirSync(shaderDir);
	for (let shader of project.shaders) {
		await compileShader(exporter, platform, project, shader, shaderDir, temp, krafix);
		if (platform === Platform.Unity) {
			fs.ensureDirSync(path.join(to, exporter.sysdir() + '-resources'));
			fs.writeFileSync(path.join(to, exporter.sysdir() + '-resources', shader.name + '.hlsl'), shader.name);
		}
	}
	if (platform === Platform.Unity) {
		let proto = fs.readFileSync(path.join(from, options.kha, 'Tools', 'khamake', 'Data', 'unity', 'Shaders', 'proto.shader'), { encoding: 'utf8' });
		for (let i1 = 0; i1 < project.exportedShaders.length; ++i1) {
			if (project.exportedShaders[i1].name.endsWith('.vert')) {
				for (let i2 = 0; i2 < project.exportedShaders.length; ++i2) {
					if (project.exportedShaders[i2].name.endsWith('.frag')) {
						let shadername = project.exportedShaders[i1].name + '.' + project.exportedShaders[i2].name;
						let proto2 = proto.replace(/{name}/g, shadername);
						proto2 = proto2.replace(/{vert}/g, project.exportedShaders[i1].name);
						proto2 = proto2.replace(/{frag}/g, project.exportedShaders[i2].name);
						fs.writeFileSync(path.join(shaderDir, shadername + '.shader'), proto2, { encoding: 'utf8' });
					}
				}
			}
		}
		let blobDir = path.join(to, exporter.sysdir(), 'Assets', 'Resources', 'Blobs');
		fs.ensureDirSync(blobDir);
		for (let i = 0; i < project.exportedShaders.length; ++i) {
			fs.writeFileSync(path.join(blobDir, project.exportedShaders[i].files[0] + '.bytes'), project.exportedShaders[i].name, { encoding: 'utf8' });
		}
	}*/
	
	fs.ensureDirSync(shaderDir);
	let shaderCompiler = new ShaderCompiler(exporter, options.target, options.krafix, shaderDir, temp, options, project.shaderMatchers);
	let exportedShaders = await shaderCompiler.run(options.watch);

	let files = [];
	for (let asset of assets) {
		files.push({
			name: fixName(asset.name),
			files: asset.files,
			type: asset.type
		});
	}
	for (let shader of exportedShaders) {
		files.push({
			name: fixName(shader.name),
			files: shader.files,
			type: 'shader'
		});
	}

	function secondPass() {
		// First pass is for main project files. Second pass is for shaders.
		// Will try to look for the folder, e.g. 'build/Shaders'.
		// if it exists, export files similar to other a
		let hxslDir = path.join('build', 'Shaders');
		/** if (fs.existsSync(hxslDir) && fs.readdirSync(hxslDir).length > 0) {
			addShaders(exporter, platform, project, from, to.resolve(exporter.sysdir() + '-resources'), temp, from.resolve(Paths.get(hxslDir)), krafix);
			if (foundProjectFile) {
				fs.outputFileSync(to.resolve(Paths.get(exporter.sysdir() + '-resources', 'files.json')).toString(), JSON.stringify({ files: files }, null, '\t'), { encoding: 'utf8' });
				log.info('Assets done.');
				exportProjectFiles(name, from, to, options, exporter, platform, khaDirectory, haxeDirectory, kore, project.libraries, project.targetOptions, callback);
			}
			else {
				exportProjectFiles(name, from, to, options, exporter, platform, khaDirectory, haxeDirectory, kore, project.libraries, project.targetOptions, callback);
			}
		}*/
	}

	if (foundProjectFile) {
		fs.outputFileSync(path.join(options.to, exporter.sysdir() + '-resources', 'files.json'), JSON.stringify({ files: files }, null, '\t'));
	}

	return await exportProjectFiles(project.name, options, exporter, kore, korehl, project.libraries, project.targetOptions, project.defines);
}
開發者ID:npretto,項目名稱:khamake,代碼行數:101,代碼來源:main.ts

示例14:

fs.mkdirs(dir).then(() => {
	// stub
});
fs.mkdirp(dir).then(() => {
	// stub
});
fs.mkdirs(dir, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirp(dir, errorCallback);
fs.mkdirpSync(dir);

fs.outputFile(file, data).then(() => {
	// stub
});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);

fs.outputJson(file, data, {
	spaces: 2
}).then(() => {
	// stub
});
fs.outputJson(file, data, {
	spaces: 2
}, errorCallback);
fs.outputJSON(file, data, errorCallback);
fs.outputJSON(file, data).then(() => {
	// stub
});

fs.outputJsonSync(file, data);
開發者ID:gilamran,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:fs-extra-tests.ts

示例15: expect

 const preparations = () => {
   fse.outputFileSync("dir1/dir2/file.txt", "abc");
   jetpack.symlink("../dir1", "foo/symlink_to_dir1");
   expect(jetpack.read("foo/symlink_to_dir1/dir2/file.txt")).to.eql("abc");
 };
開發者ID:szwacz,項目名稱:fs-jetpack,代碼行數:5,代碼來源:find.spec.ts


注:本文中的fs-extra.outputFileSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。