From e6326332b6d577c334dae154bcd63627aeba7b05 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 4 May 2015 15:08:18 +0100 Subject: [PATCH] properly coerce input code to string - fixes #1432 --- src/babel/api/node.js | 2 +- src/babel/transformation/file/index.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/babel/api/node.js b/src/babel/api/node.js index 8923446029..17bba24090 100644 --- a/src/babel/api/node.js +++ b/src/babel/api/node.js @@ -53,7 +53,7 @@ export function transformFile(filename: string, opts?: Object, callback: Functio export function transformFileSync(filename: string, opts?: Object = {}) { opts.filename = filename; - return transform(fs.readFileSync(filename), opts); + return transform(fs.readFileSync(filename, "utf8"), opts); } export function parse(code, opts = {}) { diff --git a/src/babel/transformation/file/index.js b/src/babel/transformation/file/index.js index f0b8861ad8..bec58c718a 100644 --- a/src/babel/transformation/file/index.js +++ b/src/babel/transformation/file/index.js @@ -480,6 +480,8 @@ export default class File { } wrap(code, callback) { + code = code + ""; + try { if (this.shouldIgnore()) { return {