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