babel/scripts/bootstrap.js
Sebastian McKenzie ae7d5367f1 6.0.0
I'm extremely stupid and didn't commit as I go. To anyone reading this
I'm extremely sorry. A lot of these changes are very broad and I plan on
releasing Babel 6.0.0 today live on stage at Ember Camp London so I'm
afraid I couldn't wait. If you're ever in London I'll buy you a beer
(or assorted beverage!) to make up for it, also I'll kiss your feet and
give you a back massage, maybe.
2015-10-29 17:51:24 +00:00

71 lines
1.9 KiB
JavaScript
Executable File

require("shelljs/global");
var path = require("path");
var fs = require("fs");
var OFFLINE = !!process.env.OFFLINE;
// uninstall global babel install
try {
exec("npm uninstall -g babel");
} catch (err) {}
// get packages
var packages = [];
ls("packages/*").forEach(function (loc) {
var name = path.basename(loc);
if (name[0] === ".") return;
var pkgLoc = __dirname + "/../packages/" + name + "/package.json";
if (!fs.existsSync(pkgLoc)) return;
var pkg = require(pkgLoc);
packages.push({
folder: name,
pkg: pkg,
name: pkg.name
});
});
// create links
packages.forEach(function (root) {
console.log(root.name);
var nodeModulesLoc = "packages/" + root.folder + "/node_modules";
mkdir("-p", nodeModulesLoc);
packages.forEach(function (sub) {
var valid = false;
if (root.pkg.dependencies && root.pkg.dependencies[sub.name]) valid = true;
if (root.pkg.devDependencies && root.pkg.devDependencies[sub.name]) valid = true;
if (!valid) return;
var linkSrc = "packages/" + sub.folder;
var linkDest = nodeModulesLoc + "/" + sub.name;
console.log("Linking", linkSrc, "to", linkDest);
if (fs.existsSync(linkDest)) fs.unlinkSync(linkDest);
ln("-s", linkSrc, linkDest);
});
cd("packages/" + root.folder);
// check whether or not we have any dependencies in our package.json that aren't in node_modules
var shouldRunInstall = false;
var pkg = require(process.cwd() + "/package.json");
var deps = Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.devDependencies || {}));
deps.forEach(function (depName) {
if (!fs.existsSync(process.cwd() + "/node_modules/" + depName)) {
console.log("Not installed", depName);
shouldRunInstall = true;
}
});
if (shouldRunInstall && !OFFLINE) exec("npm install");
if (!OFFLINE) exec("npm link");
cd("../..");
});
if (!OFFLINE) exec("make build");