Sha256: 189d4db349d6d597f113d88ffd70d15ef7156f27ccdbe40b8958c3b0dcba0a90
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
// @flow import gensync from "gensync"; import loadConfig, { type InputOptions, type ResolvedConfig } from "./config"; import { run, type FileResult, type FileResultCallback, } from "./transformation"; import * as fs from "./gensync-utils/fs"; import typeof * as transformFileBrowserType from "./transform-file-browser"; import typeof * as transformFileType from "./transform-file"; // Kind of gross, but essentially asserting that the exports of this module are the same as the // exports of transform-file-browser, since this file may be replaced at bundle time with // transform-file-browser. ((({}: any): $Exact<transformFileBrowserType>): $Exact<transformFileType>); type TransformFile = { (filename: string, callback: FileResultCallback): void, (filename: string, opts: ?InputOptions, callback: FileResultCallback): void, }; const transformFileRunner = gensync<[string, ?InputOptions], FileResult | null>( function* (filename, opts) { const options = { ...opts, filename }; const config: ResolvedConfig | null = yield* loadConfig(options); if (config === null) return null; const code = yield* fs.readFile(filename, "utf8"); return yield* run(config, code); }, ); export const transformFile: TransformFile = transformFileRunner.errback; export const transformFileSync = transformFileRunner.sync; export const transformFileAsync = transformFileRunner.async;
Version data entries
4 entries across 3 versions & 2 rubygems