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

TypeScript fs.writeFile函数代码示例

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

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



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

示例1: generate

/**
 * Use code generation.
 */
async function generate(): Promise<void> {
  await writeFile("./src/parser/tokenizer/types.ts", generateTokenTypes());
  await run("./node_modules/.bin/prettier --write ./src/parser/tokenizer/types.ts");
  await writeFile("./src/parser/tokenizer/readWordTree.ts", generateReadWordTree());
  await run("./node_modules/.bin/prettier --write ./src/parser/tokenizer/readWordTree.ts");
  console.log("Done with code generation.");
}
开发者ID:alangpierce,项目名称:sucrase,代码行数:10,代码来源:generate.ts


示例2:

    .then((transpiled) => {
      const sourceMap = JSON.parse(transpiled.sourceMapText);
      sourceMap['file'] = path.basename(outputFile);
      sourceMap['sources'] = [path.basename(inputFile)];

      return Promise.all([
        fs.writeFile(outputFile, transpiled.outputText),
        fs.writeFile(`${outputFile}.map`, JSON.stringify(sourceMap))
      ]);
    });
开发者ID:davidenke,项目名称:ng-packagr,代码行数:10,代码来源:tsc.ts


示例3: graphQLTypes

export async function graphQLTypes(): Promise<void> {
    const schemaStr = await readFile(GRAPHQL_SCHEMA_PATH, 'utf8')
    const schema = buildSchema(schemaStr)
    const result = (await graphql(schema, introspectionQuery)) as { data: IntrospectionQuery }

    const formatOptions = (await resolveConfig(__dirname, { config: __dirname + '/../prettier.config.js' }))!
    const typings =
        'export type ID = string\n\n' +
        generateNamespace(
            '',
            result,
            {
                typeMap: {
                    ...DEFAULT_TYPE_MAP,
                    ID: 'ID',
                },
            },
            {
                generateNamespace: (name: string, interfaces: string) => interfaces,
                interfaceBuilder: (name: string, body: string) =>
                    'export ' + DEFAULT_OPTIONS.interfaceBuilder(name, body),
                enumTypeBuilder: (name: string, values: string) =>
                    'export ' + DEFAULT_OPTIONS.enumTypeBuilder(name, values),
                typeBuilder: (name: string, body: string) => 'export ' + DEFAULT_OPTIONS.typeBuilder(name, body),
                wrapList: (type: string) => `${type}[]`,
                postProcessor: (code: string) => format(code, { ...formatOptions, parser: 'typescript' }),
            }
        )
    await writeFile(__dirname + '/src/graphql/schema.ts', typings)
}
开发者ID:JoYiRis,项目名称:sourcegraph,代码行数:30,代码来源:gulpfile.ts


示例4: getTLSCertificate

export async function getTLSCertificate(
    keyPath: string, certPath: string): Promise<KeyAndCert> {
  let certObj = await _readKeyAndCert(keyPath, certPath);

  if (!certObj) {
    certObj = await createTLSCertificate();

    if (keyPath && certPath) {
      await Promise.all([
        fs.writeFile(certPath, certObj.cert),
        fs.writeFile(keyPath, certObj.key)
      ]);
    }
  }

  return certObj;
}
开发者ID:tony19-contrib,项目名称:polyserve,代码行数:17,代码来源:tls.ts


示例5: buildFile

async function buildFile(srcPath: string, outPath: string, options: CLIOptions): Promise<void> {
  if (!options.quiet) {
    console.log(`${srcPath} -> ${outPath}`);
  }
  const code = (await readFile(srcPath)).toString();
  const transformedCode = transform(code, {...options.sucraseOptions, filePath: srcPath}).code;
  await writeFile(outPath, transformedCode);
}
开发者ID:alangpierce,项目名称:sucrase,代码行数:8,代码来源:cli.ts


示例6: processFile

 async function processFile(path: string): Promise<void> {
   let extension = path.endsWith('.coffee.md') ? '.coffee.md' : extname(path);
   let outputPath = join(dirname(path), basename(path, extension)) + '.js';
   console.log(`${path} → ${outputPath}`);
   let data = await readFile(path, 'utf8');
   let resultCode = runWithCode(path, data, options);
   await writeFile(outputPath, resultCode);
 }
开发者ID:alangpierce,项目名称:decaffeinate,代码行数:8,代码来源:cli.ts


示例7: writeThingSchemaToFilesAsync

    public static async writeThingSchemaToFilesAsync(
            thingSchema: ThingSchema, ramlFilePath: string): Promise<void> {
        let ramlAndJson: { raml: string, json: {[fileName: string]: string}} =
                await OcfSchemaWriter.writeThingSchema(thingSchema);
        await fs.writeFile(ramlFilePath, ramlAndJson.raml, "utf8");

        // TODO: Write each of the JSON files to the same directory as the raml file.
    }
开发者ID:arjun-msft,项目名称:opent2t,代码行数:8,代码来源:OcfSchemaWriter.ts


示例8: async

export const writeBaselineFile = async (filePath: string, contents: string[], commentMarker: string | undefined): Promise<void> => {
    if (commentMarker !== undefined) {
        contents = [commentMarker.trim(), ...contents, commentMarker.trim(), ""];
    } else {
        contents = [...contents, ""];
    }

    await mkdirpPromise(path.dirname(filePath));
    await fs.writeFile(filePath, contents.join("\n"));
};
开发者ID:HighSchoolHacking,项目名称:GLS,代码行数:10,代码来源:Files.ts


示例9: writeOutput

function writeOutput(ts: string, argOut: string): Promise<void> {
  if (!argOut) {
    try {
      process.stdout.write(ts)
      return Promise.resolve()
    } catch (err) {
      return Promise.reject(err)
    }
  }
  return writeFile(argOut, ts)
}
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:11,代码来源:cli.ts


示例10: async

export const testCSharpGenerator: IOutputGenerator = async ({ projectDirectory, projectName }): Promise<string[]> => {
    const csprojPath = path.join(projectDirectory, projectName + ".csproj");

    await fs.writeFile(csprojPath, template, {
        flag: "w",
    });

    return spawnAndCaptureOutput("dotnet", {
        args: ["run", "--project", csprojPath],
    });
};
开发者ID:HighSchoolHacking,项目名称:GLS,代码行数:11,代码来源:CSharpOutputGenerator.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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