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


TypeScript fs.writeFileSync函数代码示例

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


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

示例1: readFileSync

const copyFile = (name: string, from: string, to: string, mod: any = (f: string) => f) => {
  const file = readFileSync(join(from, name));
  writeFileSync(join(to, name), mod(file.toString()));
};
开发者ID:adrianfaciu,项目名称:angular2-seed,代码行数:4,代码来源:compile.ahead.prod.ts

示例2: function

  let ext = infile.split('.').pop()
  // Skip .html and pass-through inputs.
  if (!(ext === 'html' || (pass && infile === STDIN))) {
    options.callback = function (message): void {
      let msg = message.type + ': ' + infile + ': ' + message.text
      if (msg.length > 120) {
        msg = msg.slice(0, 117) + '...'
      }
      console.error(msg)
      if (message.type === 'error') {
        errors += 1
      }
    }
    source = rimu.render(source, options)
  }
  source = source.trim()
  if (source !== '') {
    output += source + '\n'
  }
}
output = output.trim()
if (!outfile || outfile === '-') {
  process.stdout.write(output)
}
else {
  fs.writeFileSync(outfile, output)
}
if (errors) {
  process.exit(1)
}
开发者ID:srackham,项目名称:rimu,代码行数:30,代码来源:rimuc.ts

示例3: writeTestConfigFile

// used to pass data from jake command line directly to run.js
function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) {
    const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder });
    console.log("Running tests with config: " + testConfigContents);
    fs.writeFileSync("test.config", testConfigContents);
}
开发者ID:sepiropht,项目名称:atoms.config,代码行数:6,代码来源:Gulpfile.ts

示例4: writeTextFile

  export function writeTextFile(name: string, value: string) {
     mkdirRecursiveSync(PATH.dirname(name));
     FS.writeFileSync(name, value, "utf8");
 }
开发者ID:LordZardeck,项目名称:cats,代码行数:4,代码来源:os.ts

示例5: writeFileSync

 promises.push(Promise.resolve(codegen.emit()).then((code) => {
   writeFileSync(outDir + file + '.ts', code);
 }));
开发者ID:JheynsFenix,项目名称:angular,代码行数:3,代码来源:index.ts

示例6: build

function build()
{
	let path = pathlib.resolve(BUILD_PATH);
	let option_file_path = pathlib.join(path, 'buildoption.json');

	watch_file_list = [option_file_path];
	let info = JSON.parse(fs.readFileSync(option_file_path, 'utf8'));

	let body_files = info.body.map(x => pathlib.join(path, x));
	let css_files = info.css.map(x => pathlib.join(path, x));
	let javascript_files = info.javascript.map(x => pathlib.join(path, x));
	let webworker_files = info.webworker.map(x => pathlib.join(path, x));

	watch_file_list = watch_file_list.concat(body_files, css_files, javascript_files, webworker_files);

	let body = concat(body_files);
	let css = concat(css_files);
	let javascript = concat(javascript_files);
	webworker_result = concat(webworker_files);
	javascript += `
	function __GET_GAME_CONFIG()
	{
		return ${JSON.stringify(getBuildConfigObject())};
	}
	`
	webworker_result += `
	function __GET_GAME_CONFIG()
	{
		return ${JSON.stringify(getBuildConfigObject())};
	}
	`

	if (0)
	{
		let options = {
			fromString: true,
			warnings: false,
			mangleProperties: false
		};
		{
			let new_javascript = UglifyJS.minify(javascript, options);
			console.log(`compress javascript from ${javascript.length / 1024}KB to ${new_javascript.code.length / 1024}KB`);
			javascript = new_javascript.code;
		}

		{
			let new_webworker_result = UglifyJS.minify(webworker_result, options);
			console.log(`compress webworker js from ${webworker_result.length / 1024}KB to ${new_webworker_result.code.length / 1024}KB`);
			webworker_result = new_webworker_result.code;
		}
	}



	fs.writeFileSync(joinpath(path, '__bundle.js'), javascript, { encoding: 'utf8' });
	fs.writeFileSync(joinpath(path, '__worker_bundle.js'), webworker_result, { encoding: 'utf8' });
	/*
	javascript += `
	window.FILE_VERSIONS = ${JSON.stringify(genImageVersions())}
	`;*/
	return { body, css, javascript };
}
开发者ID:hUangDDD,项目名称:bally,代码行数:62,代码来源:builder.ts

示例7: require

declare const require: any;
declare const process: any;
const fs = require('fs');
const args = process.argv;

const outputPath = args[2];
args.splice(0, 3);

let bundle = '';
args.forEach(file => {
  let content = fs.readFileSync(file, {encoding: 'utf-8'});
  bundle += '\n\n' + content;
});

fs.writeFileSync(outputPath, bundle);
开发者ID:thelgevold,项目名称:angular-2-samples,代码行数:15,代码来源:concat.ts

示例8: rdSync

          return;
        }
        symLinks[lstat.dev][lstat.ino] = true;
      }
      const fstat = fs.statSync(fpath);
      if (fstat.isDirectory()) {
        const child = tree[file] = {}
        rdSync(fpath, child, file)
      } else {
        tree[file] = null
      }
    } catch (e) {
      // Ignore and move on.
    }
  });
  return tree
}

const fsListing = JSON.stringify(rdSync(process.cwd(), {}, '/'));
if (process.argv.length === 3) {
  const fname = process.argv[2];
  let parent = path.dirname(fname);
  while (!fs.existsSync(parent)) {
    fs.mkdirSync(parent);
    parent = path.dirname(parent);
  }
  fs.writeFileSync(fname, fsListing, { encoding: 'utf8' });
} else {
  console.log(fsListing);
}
开发者ID:diegolameira,项目名称:codesandbox-client,代码行数:30,代码来源:make_http_index.ts

示例9: before

 before(() => {
     fs.writeFileSync(inputPath, fileContent);
     testFunc = () => new SourceCodeReader({
         exclude: [`**/${tmpFileName}`]
     }).readSourceCode(inputPath);
 });
开发者ID:dssoft32,项目名称:javascript-obfuscator,代码行数:6,代码来源:SourceCodeReader.spec.ts

示例10: createRandomFile

export async function createRandomFile(contents: string, fileExtension: string): Promise<string> {
  const tmpFile = join(os.tmpdir(), rndName() + fileExtension);
  fs.writeFileSync(tmpFile, contents);
  return tmpFile;
}
开发者ID:octref,项目名称:Vim,代码行数:5,代码来源:testUtils.ts


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