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