Created
March 3, 2017 06:13
-
-
Save aaronang/51261cf9ab4702f07aa53c82ea06cc06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function transform(filename, code, opts) { | |
opts = defaults(opts || {}, index.opts); | |
opts.filename = filename; | |
const result = babel.transform(code, opts); | |
result.filename = filename; | |
result.actual = code; | |
return result; | |
} | |
export function compile(filename, opts) { | |
try { | |
const code = fs.readFileSync(filename, "utf8"); | |
return transform(filename, code, opts); | |
} catch (err) { | |
if (commander.watch) { | |
console.error(toErrorStack(err)); | |
return { ignored: true }; | |
} else { | |
throw err; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment