From 4476e8311cf88f5b0a9ef111be1e7b23d6b96b29 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 25 Jun 2015 23:20:18 +0100 Subject: [PATCH] use relative tools/protect.js filenames --- tools/build-plugins/protect.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/build-plugins/protect.js b/tools/build-plugins/protect.js index cefd25e1f4..b0b5f1de99 100644 --- a/tools/build-plugins/protect.js +++ b/tools/build-plugins/protect.js @@ -1,3 +1,5 @@ +var path = require("path"); + module.exports = function (babel) { var t = babel.types; @@ -7,8 +9,13 @@ module.exports = function (babel) { if (file.opts.filename.indexOf("tools/protect") >= 0) return; if (file.opts.filename.indexOf("templates") >= 0) return; + var from = "/" + path.dirname(file.opts.filename.replace(/^src/, "lib")); + var to = "/lib/babel/tools"; + + var protectLoc = "./" + path.relative(from, to) + "/protect.js"; + this.unshiftContainer("body", [ - t.expressionStatement(t.callExpression(file.addImport("babel-core/lib/babel/tools/protect"), [t.identifier("module")])) + t.expressionStatement(t.callExpression(file.addImport(protectLoc), [t.identifier("module")])) ]); } }