• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fs-extra.outputFileSync函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中fs-extra.outputFileSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript outputFileSync函数的具体用法?TypeScript outputFileSync怎么用?TypeScript outputFileSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了outputFileSync函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: hxml

function hxml(projectdir: string, options: any) {
	let data = '';
	let lines: Array<String> = [];

	// returns only unique lines and '' otherwise
	function unique(line: String): String {
		if (lines.indexOf(line) === -1) {
			lines.push(line);
			return line;
		}		
		return '';
	}

	for (let i = 0; i < options.sources.length; ++i) {
		if (path.isAbsolute(options.sources[i])) {
			data += unique('-cp ' + options.sources[i] + '\n');
		}
		else {
			data += unique('-cp ' + path.relative(projectdir, path.resolve(options.from, options.sources[i])) + '\n'); // from.resolve('build').relativize(from.resolve(this.sources[i])).toString());
		}
	}
	for (let i = 0; i < options.libraries.length; ++i) {
		if (path.isAbsolute(options.libraries[i].libpath)) {
			data += unique('-cp ' + options.libraries[i].libpath + '\n');
		}
		else {
			data += unique('-cp ' + path.relative(projectdir, path.resolve(options.from, options.libraries[i].libpath)) + '\n'); // from.resolve('build').relativize(from.resolve(this.sources[i])).toString());
		}
	}
	for (let d in options.defines) {
		let define = options.defines[d];
		data += unique('-D ' + define + '\n');
	}
	if (options.language === 'cpp') {
		data += unique('-cpp ' + path.normalize(options.to) + '\n');
	}
	else if (options.language === 'cs') {
		data += unique('-cs ' + path.normalize(options.to) + '\n');
		if (fs.existsSync(options.haxeDirectory) && fs.statSync(options.haxeDirectory).isDirectory() && fs.existsSync(path.join(options.haxeDirectory, 'netlib'))) {
			data += unique('-net-std ' + path.relative(projectdir, path.join(options.haxeDirectory, 'netlib')) + '\n');
		}
	}
	else if (options.language === 'java') {
		data += unique('-java ' + path.normalize(options.to) + '\n');
		if (fs.existsSync(options.haxeDirectory) && fs.statSync(options.haxeDirectory).isDirectory() && fs.existsSync(path.join(options.haxeDirectory, 'hxjava', 'hxjava-std.jar'))) {
			data += unique('-java-lib ' + path.relative(projectdir, path.join(options.haxeDirectory, 'hxjava', 'hxjava-std.jar')) + '\n');
		}
	}
	else if (options.language === 'js') {
		data += unique('-js ' + path.normalize(options.to) + '\n');
	}
	else if (options.language === 'as') {
		data += unique('-swf ' + path.normalize(options.to) + '\n');
		data += unique('-swf-version ' + options.swfVersion + '\n');
		data += unique('-swf-header ' + options.width + ':' + options.height + ':' + options.framerate + ':' + options.stageBackground + '\n');
	}
	else if (options.language === 'xml') {
		data += unique('-xml ' + path.normalize(options.to) + '\n');
		data += unique('--macro include(\'kha\')\n');
	}
	else if (options.language === 'hl') {
		data += unique('-hl ' + path.normalize(options.to) + '\n');
	}
	for (let param of options.parameters) {
		data += unique(param + '\n');
	}

	if (!options.parameters.some((param: string) => param.includes('-main '))) {
		const entrypoint = options ? options.main ? options.main : 'Main' : 'Main';
		data += unique('-main ' + entrypoint + '\n');	
	}

	fs.outputFileSync(path.join(projectdir, 'project-' + options.system + '.hxml'), data);
}
开发者ID:KTXSoftware,项目名称:khamake,代码行数:74,代码来源:HaxeProject.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra.outputJson函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra.outputFile函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap