rewrite bootstrap script to use shelljs as the bootstraping process is kinda weird now with multiple packages

This commit is contained in:
Sebastian McKenzie 2015-07-14 16:48:20 +01:00
parent 0c7c73435c
commit 7c8f3ed696
4 changed files with 47 additions and 29 deletions

View File

@ -1 +1,2 @@
packages/babel/src/transformation/templates
scripts

View File

@ -48,4 +48,5 @@ publish: build-dist
./scripts/build-website.sh
bootstrap:
./scripts/bootstrap.sh
npm install
node scripts/bootstrap.js

44
scripts/bootstrap.js vendored Executable file
View File

@ -0,0 +1,44 @@
var path = require("path");
var fs = require("fs");
require("shelljs/global");
exec("npm list --global --depth 1 babel >/dev/null 2>&1 && npm uninstall -g babel || true");
// get packages
var packages = [];
ls("packages/*").forEach(function (loc) {
var name = path.basename(loc);
if (name[0] !== ".") {
var pkg = require("../packages/" + name + "/package.json");
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) {
if (!root.pkg.dependencies || !root.pkg.dependencies[sub.name]) return;
if (!fs.existsSync(nodeModulesLoc + "/" + sub.name)) {
ln("-s", "packages/" + sub.folder, nodeModulesLoc + "/" + sub.name);
}
});
cd("packages/" + root.folder);
exec("npm install");
exec("npm link");
cd("../..");
});
exec("git submodule update --init");
exec("make build");

View File

@ -1,28 +0,0 @@
#!/bin/sh
set -e
#
export NODE_PATH="`pwd`/packages;$NODE_PATH"
# install default set
npm install
# remove global babel
npm list --global --depth 1 babel >/dev/null 2>&1 && npm uninstall -g babel || true
for f in packages/*; do
if [ -d $f ]; then
cd $f
if [ -f "package.json" ]; then
npm install
npm link
fi
if [ -f "scripts/bootstrap.sh" ]; then
./scripts/bootstrap.sh
fi
cd ../..
fi
done
git submodule update --init
make build