This commit is contained in:
Sebastian McKenzie 2015-07-13 23:37:01 +01:00
parent dfbb6604e7
commit 2f212cea0a
7 changed files with 128 additions and 21 deletions

View File

@ -1,5 +1,6 @@
{
"name": "babel",
"version": "5.6.21",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -7,7 +8,7 @@
"repository": "babel/babel",
"preferGlobal": true,
"dependencies": {
"babel": "*",
"babel": "^5.6.21",
"chokidar": "^1.0.0",
"commander": "^2.6.0",
"convert-source-map": "^1.1.0",

View File

@ -1,5 +1,6 @@
{
"name": "babel-runtime",
"version": "5.6.21",
"description": "babel selfContained runtime",
"license": "MIT",
"repository": "babel/babel",

View File

@ -1,5 +1,6 @@
{
"name": "babel-core",
"version": "5.6.21",
"description": "A compiler for writing next generation JavaScript",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -41,7 +42,7 @@
"babel-plugin-runtime": "^1.0.7",
"babel-plugin-undeclared-variables-check": "^1.0.2",
"babel-plugin-undefined-to-void": "^1.1.6",
"babylon": "*",
"babylon": "^5.6.21",
"bluebird": "^2.9.33",
"chalk": "^1.0.0",
"convert-source-map": "^1.1.0",

View File

@ -56,6 +56,10 @@ export function getCompletionRecords(): Array {
add(this.get("body").pop());
} else if (this.isFunction()) {
return this.get("body").getCompletionRecords();
} else if (this.isTryStatement()) {
add(this.get("block"));
add(this.get("handler"));
add(this.get("finalizer"));
} else {
paths.push(this);
}

View File

@ -156,19 +156,18 @@ export function replaceExpressionWithStatements(nodes: Array) {
// add implicit returns to all ending expression statements
var last = this.get("callee").getCompletionRecords();
for (var i = 0; i < last.length; i++) {
var lastNode = last[i];
if (lastNode.isExpressionStatement()) {
var loop = lastNode.findParent((path) => path.isLoop());
if (loop) {
var uid = this.get("callee").scope.generateDeclaredUidIdentifier("ret");
this.get("callee.body").pushContainer("body", t.returnStatement(uid));
lastNode.get("expression").replaceWith(
t.assignmentExpression("=", uid, lastNode.node.expression)
);
} else {
lastNode.replaceWith(t.returnStatement(lastNode.node.expression));
}
for (var lastNode of (last: Array)) {
if (!lastNode.isExpressionStatement()) continue;
var loop = lastNode.findParent((path) => path.isLoop());
if (loop) {
var uid = this.get("callee").scope.generateDeclaredUidIdentifier("ret");
this.get("callee.body").pushContainer("body", t.returnStatement(uid));
lastNode.get("expression").replaceWith(
t.assignmentExpression("=", uid, lastNode.node.expression)
);
} else {
lastNode.replaceWith(t.returnStatement(lastNode.node.expression));
}
}

View File

@ -1,5 +1,6 @@
{
"name": "babylon",
"version": "5.6.21",
"description": "",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",

View File

@ -1,3 +1,103 @@
var fs = require("fs");
var readline = require("readline-sync");
var semver = require("semver");
var child = require("child_process");
var fs = require("fs");
var packageNames = fs.readDirSync(__filename + "/../packages");
var PACKAGE_LOC = __dirname + "/../packages";
var VERSION_LOC = __dirname + "/../VERSION";
var CURRENT_VERSION = fs.readFileSync(VERSION_LOC, "utf8").trim();
console.log("Current version:", CURRENT_VERSION);
//
function getVersion() {
var input = readline.question("New version (Leave blank for new patch): ");
var ver = semver.valid(input);
if (!ver) {
ver = semver.inc(CURRENT_VERSION, input || "patch");
}
if (ver) {
return ver;
} else {
console.log("Version provided is not valid semver.");
return getVersion();
}
}
var NEW_VERSION = getVersion();
fs.writeFileSync(VERSION_LOC, NEW_VERSION, "utf8");
//
function exec(cmd, log) {
console.log("$", cmd);
var out = child.execSync(cmd, {
encoding: "utf8"
}).trim();
if (log) {
console.log(out);
} else {
return out;
}
}
function getPackageLocation(name) {
return PACKAGE_LOC + "/" + name;
}
//
var packageNames = fs.readdirSync(PACKAGE_LOC).filter(function (name) {
return name[0] !== ".";
});
var lastTagCommit = exec("git rev-list --tags --max-count=1");
var lastTag = exec("git describe " + lastTagCommit);
var changedPackages = [];
var changedFiles = [];
packageNames.forEach(function (name) {
var diff = exec("git diff " + lastTag + " -- " + getPackageLocation(name));
if (diff) {
console.log("Changes detected to package", name);
changedPackages.push(name);
}
});
//
changedPackages.forEach(function (name) {
var loc = getPackageLocation(name);
var pkgLoc = loc + "/package.json";
var pkg = require(pkgLoc);
pkg.version = NEW_VERSION;
for (var depName in pkg.dependencies) {
if (changedPackages.indexOf(depName) >= 0) {
pkg.dependencies[depName] = "^" + NEW_VERSION;
}
}
fs.writeFileSync(pkgLoc, JSON.stringify(pkg, null, " "));
changedFiles.push(pkgLoc);
});
changedFiles.forEach(function (loc) {
exec("git add " + loc, true);
});
var NEW_TAG_NAME = "v" + NEW_VERSION;
exec("git commit -m " + NEW_TAG_NAME, true);
exec("git tag " + NEW_TAG_NAME, true);
exec("git push --follow-tags", true);
changedPackages.forEach(function (name) {
//exec("cd " + getPackageLocation(name) + " && npm publish", true);
});