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


TypeScript fs.writeFile函数代码示例

本文整理汇总了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;未经允许,请勿转载。