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

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

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

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



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

示例1: it

    it('can commit when a delete is staged and the untracked file exists', async () => {
      let status,
        files = null

      const repo = await setupEmptyRepository()

      const firstPath = path.join(repo.path, 'first')
      fs.writeFileSync(firstPath, 'line1\n')

      await GitProcess.exec(['add', 'first'], repo.path)
      await GitProcess.exec(['commit', '-am', 'commit first file'], repo.path)
      await GitProcess.exec(['rm', '--cached', 'first'], repo.path)

      // if the text is now different, everything is fine
      fs.writeFileSync(firstPath, 'line2\n')

      status = await getStatus(repo)
      files = status.workingDirectory.files

      expect(files.length).to.equal(1)
      expect(files[0].path).to.contain('first')
      expect(files[0].status).to.equal(AppFileStatus.New)

      const toCommit = status.workingDirectory.withIncludeAllFiles(true)

      await createCommit(repo, 'commit again!', toCommit.files)

      status = await getStatus(repo)
      files = status.workingDirectory.files
      expect(files).to.be.empty

      const commit = await getCommit(repo, 'HEAD')
      expect(commit).to.not.be.null
      expect(commit!.summary).to.equal('commit again!')
    })
开发者ID:Ahskys,项目名称:desktop,代码行数:35,代码来源:commit-test.ts


示例2: exportSolution

	exportSolution(project: Project, from: string, to: string, platform: string) {
		if (project.getDebugDir() !== '') fs.copySync(path.resolve(from, project.getDebugDir()), path.resolve(to, 'data'), { clobber: true });

		let dotcproject = fs.readFileSync(path.resolve(__dirname, 'Data', 'tizen', '.cproject'), 'utf8');
		dotcproject = dotcproject.replace(/{ProjectName}/g, project.getName());
		let includes = '';
		for (let include of project.getIncludeDirs()) {
			includes += '<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/CopiedSources/' + include + '}&quot;"/>';
		}
		dotcproject = dotcproject.replace(/{includes}/g, includes);
		let defines = '';
		for (let define of project.getDefines()) {
			defines += '<listOptionValue builtIn="false" value="' + define + '"/>';
		}
		dotcproject = dotcproject.replace(/{defines}/g, defines);
		fs.writeFileSync(path.resolve(to, '.cproject'), dotcproject);

		let dotproject = fs.readFileSync(path.resolve(__dirname, 'Data', 'tizen', '.project'), 'utf8');
		dotproject = dotproject.replace(/{ProjectName}/g, project.getName());
		fs.writeFileSync(path.resolve(to, '.project'), dotproject);

		let manifest = fs.readFileSync(path.resolve(__dirname, 'Data', 'tizen', 'manifest.xml'), 'utf8');
		manifest = manifest.replace(/{ProjectName}/g, project.getName());
		fs.writeFileSync(path.resolve(to, 'manifest.xml'), manifest);

		for (let file of project.getFiles()) {
			let target = path.resolve(to, 'CopiedSources', file);
			fs.ensureDirSync(path.join(target.substr(0, target.lastIndexOf('/'))));
			fs.copySync(path.resolve(from, file), target, { clobber: true });
		}
	}
开发者ID:hammeron-art,项目名称:koremake,代码行数:31,代码来源:TizenExporter.ts


示例3: function

walk.filesSync(dataDirectory, function(dir: string, file: string, stat: any) {
	// If the file isn't a JSON, skip it.
	if (!file.match(/\.json$/)) { return; }

	// Combine them together into the relevant filenames.
	var distDir = dir.replace(dataDirectory, distDirectory);
	var dataFilename = path.join(dir, file);
	var distFilename = path.join(distDir, file);

	console.log("file", distFilename.replace(distDirectory, "").substr(1));

	// Load the file into memory.
	var fileData = fs.readFileSync(dataFilename).toString();
	var stripData = stripJsonComments(fileData, {whitespace: true});
	var data = JSON.parse(stripData);
	var minData = JSON.stringify(data, null, 0);

	// Write out the two versions.
	fs.writeFileSync(distFilename, stripData);
	fs.writeFileSync(distFilename.replace(".json", ".min.json"), minData);

	// Add the full object to the combined list.
	combined[data.id] = data;

	// Create an index-only version.
	index[data.id] = {
		id: data.id,
		type: data.type,
		version: data.version
	};

	if (data.description) { index[data.id].description = data.description; }
});
开发者ID:dmoonfire,项目名称:mfgames-culture-data,代码行数:33,代码来源:init.ts


示例4: exportResources

	exportResources() {
		this.createDirectory(path.join(this.options.to, this.sysdir() + '-build', 'shaders'));
		fs.writeFileSync(path.join(this.options.to, this.sysdir() + '-build', 'shaders', 'Simple.fcg'),
			'void main(float4 out Color : COLOR, uniform float4 MaterialColor) {\n'
			+ '\tColor = MaterialColor;\n'
			+ '}\n');

		fs.writeFileSync(path.join(this.options.to, this.sysdir() + '-build', 'shaders', 'Simple.vcg'),
			'void main(float4 in a_Position : POSITION, float4 out v_Position : POSITION, uniform float4x4 WorldViewProj) {\n'
			+ '\tv_Position = mul(a_Position, WorldViewProj);\n'
			+ '}\n');

		fs.writeFileSync(path.join(this.options.to, this.sysdir() + '-build', 'shaders', 'Texture.fcg'),
			'void main(float2 in  v_TexCoord : TEXCOORD0, float4 out Color : COLOR, uniform sampler2D Texture0 : TEXUNIT0) {\n'
			+ '\tColor = tex2D(Texture0, v_TexCoord);\n'
			+ '}\n');

		fs.writeFileSync(path.join(this.options.to, this.sysdir() + '-build', 'shaders', 'Texture.vcg'),
			'void main(float4 in a_Position : POSITION, float2 in a_TexCoord : TEXCOORD0, float4 out v_Position : POSITION, float2 out v_TexCoord : TEXCOORD0, uniform float4x4 WorldViewProj) {\n'
			+ '\tv_Position = mul(a_Position, WorldViewProj);\n'
			+ '\tv_TexCoord  = a_TexCoord;\n'
			+ '}\n');

		let appxml = path.join(this.options.to, this.sysdir() + '-build', 'app.xml');
		if (!fs.existsSync(appxml)) {
			let appxmltext = fs.readFileSync(path.join(__dirname, 'Data', 'psm', 'app.xml'), {encoding: 'utf8'});
			fs.writeFileSync(appxml.toString(), appxmltext);
		}
	}
开发者ID:KTXSoftware,项目名称:khamake,代码行数:29,代码来源:PlayStationMobileExporter.ts


示例5: it

    it('only shows modifications after move for a renamed and modified file', async () => {
      const repo = await setupEmptyRepository()

      fs.writeFileSync(path.join(repo.path, 'foo'), 'foo\n')

      await GitProcess.exec(['add', 'foo'], repo.path)
      await GitProcess.exec(['commit', '-m', 'Initial commit'], repo.path)
      await GitProcess.exec(['mv', 'foo', 'bar'], repo.path)

      fs.writeFileSync(path.join(repo.path, 'bar'), 'bar\n')

      const status = await getStatus(repo)
      const files = status.workingDirectory.files

      expect(files.length).to.equal(1)

      const diff = await getTextDiff(repo, files[0])

      expect(diff.hunks.length).to.equal(1)

      const first = diff.hunks[0]
      expect(first.lines.length).to.equal(3)
      expect(first.lines[1].text).to.equal('-foo')
      expect(first.lines[2].text).to.equal('+bar')
    })
开发者ID:Ahskys,项目名称:desktop,代码行数:25,代码来源:diff-test.ts


示例6: initProjectFile

function initProjectFile() {
  // generator app.json
  const appJsonObject = Object.assign({
    name: _.camelCase(require(path.join(process.cwd(), 'package.json')).name)
  }, rnConfig.appJson)
  // generator .${tempPath}/package.json TODO JSON.parse 这种写法可能会有隐患
  const pkgTempObj = JSON.parse(
    ejs.render(pkgTmpl, {
        projectName: _.camelCase(projectConfig.projectName),
        version: Util.getPkgVersion()
      }
    ).replace(/(\r\n|\n|\r|\s+)/gm, '')
  )
  const dependencies = require(path.join(process.cwd(), 'package.json')).dependencies
  pkgTempObj.dependencies = Object.assign({}, pkgTempObj.dependencies, dependencies)

  const indexJsStr = `
  import {AppRegistry} from 'react-native';
  import App from './${entryBaseName}';
  import {name as appName} from './app.json';

  AppRegistry.registerComponent(appName, () => App);`

  fs.writeFileSync(path.join(tempDir, 'index.js'), indexJsStr)
  Util.printLog(processTypeEnum.GENERATE, 'index.js', path.join(tempPath, 'index.js'))
  fs.writeFileSync(path.join(tempDir, 'app.json'), JSON.stringify(appJsonObject, null, 2))
  Util.printLog(processTypeEnum.GENERATE, 'app.json', path.join(tempPath, 'app.json'))
  fs.writeFileSync(path.join(tempDir, 'package.json'), JSON.stringify(pkgTempObj, null, 2))
  Util.printLog(processTypeEnum.GENERATE, 'package.json', path.join(tempPath, 'package.json'))
}
开发者ID:YangShaoQun,项目名称:taro,代码行数:30,代码来源:rn.ts


示例7: exportCLion

	exportCLion(project: Project, from: string, to: string, platform: string, vrApi: any, nokrafix: boolean, options: any) {
		let name = project.getName().replace(/ /g, '_');

		const indir = path.join(__dirname, '..', '..', 'Data', 'linux');
		fs.ensureDirSync(path.resolve(to, project.getName(), '.idea'));
		
		let misc = fs.readFileSync(path.join(indir, 'idea', 'misc.xml'), 'utf8');
		misc = misc.replace(/{root}/g, path.resolve(from));
		fs.writeFileSync(path.join(to, project.getName(), '.idea', 'misc.xml'), misc, 'utf8');

		let workspace = fs.readFileSync(path.join(indir, 'idea', 'workspace.xml'), 'utf8');
		workspace = workspace.replace(/{workingdir}/g, path.resolve(project.getDebugDir()));
		workspace = workspace.replace(/{project}/g, project.getName());
		workspace = workspace.replace(/{target}/g, name);
		fs.writeFileSync(path.join(to, project.getName(), '.idea', 'workspace.xml'), workspace, 'utf8');

		this.writeFile(path.resolve(to, project.getName(), 'CMakeLists.txt'));

		this.p('cmake_minimum_required(VERSION 3.6)');
		this.p('project(' + name + ')');
		
		if (project.cpp11) {
			this.p('set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -static-libgcc -static-libstdc++")');
		}
		else {
			this.p('set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -static-libgcc -static-libstdc++")');
		}

		let defines = '';
		for (let def of project.getDefines()) {
			defines += '  -D' + def + '\n';
		}
		this.p('add_definitions(\n' + defines + ')');

		let includes = '';
		for (let inc of project.getIncludeDirs()) {
			includes += '  "' + path.resolve(inc).replace(/\\/g, '/') + '"\n';
		}
		this.p('include_directories(\n' + includes + ')');

		let files = '';
		for (let file of project.getFiles()) {
			if (file.file.endsWith('.c') || file.file.endsWith('.cc') || file.file.endsWith('.cpp') || file.file.endsWith('.h')) {
				files += '  "' + path.resolve(file.file).replace(/\\/g, '/') + '"\n';
			}
		}
		this.p('set(SOURCE_FILES\n' + files + ')');

		this.p('add_executable(' + name + ' ${SOURCE_FILES})');

		let libraries = '';
		for (let lib of project.getLibs()) {
			libraries += '  ' + lib + '\n';
		}
		this.p('target_link_libraries(' + name + '\n' + libraries + ')');

		this.closeFile();
	}
开发者ID:hammeron-art,项目名称:koremake,代码行数:58,代码来源:LinuxExporter.ts


示例8: uglifyFile

/** Minifies a JavaScript file using UglifyJS2. Also writes sourcemaps to the output. */
function uglifyFile(inputPath: string, outputPath: string) {
  let sourcemapOut = `${outputPath}.map`;
  let result = uglify.minify(inputPath, {
    preserveComments: 'license',
    outSourceMap: sourcemapOut
  });

  writeFileSync(outputPath, result.code);
  writeFileSync(sourcemapOut, result.map);
}
开发者ID:jcannata,项目名称:material2,代码行数:11,代码来源:package-build.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra.writeJSON函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra.writeFile函数代码示例发布时间: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