Skip to content

Commit

Permalink
Configured prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Aug 3, 2017
1 parent 9b6ebc0 commit 9d927ae
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 105 deletions.
6 changes: 6 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"*.js": [
"prettier --trailing-comma es5 --write",
"git add"
]
}
21 changes: 0 additions & 21 deletions bin/regenerator

This file was deleted.

17 changes: 17 additions & 0 deletions bin/regenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node

var compile = require("../main").compile;

require("commoner")
.version(require("../package.json").version)
.resolve(function(id) {
return this.readModuleP(id);
})
.option("-r, --include-runtime", "Prepend the runtime to the output.")
.option("--disable-async", "Disable transformation of async functions.")
.process(function(id, source) {
return compile(source, {
includeRuntime: this.options.includeRuntime,
disableAsync: this.options.disableAsync,
}).code;
});
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
"url": "git://github.com/facebook/regenerator.git"
},
"main": "main.js",
"bin": "bin/regenerator",
"bin": "bin/regenerator.js",
"scripts": {
"bootstrap": "lerna bootstrap",
"precommit": "lint-staged",
"test": "node test/run.js"
},
"dependencies": {
Expand Down Expand Up @@ -53,8 +54,11 @@
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-env": "^1.2.2",
"babylon": "^6.14.1",
"husky": "^0.14.3",
"lerna": "^2.0.0",
"lint-staged": "^4.0.2",
"mocha": "^2.3.4",
"prettier": "^1.5.3",
"promise": "^7.0.4",
"semver": "^5.0.3"
},
Expand Down
160 changes: 77 additions & 83 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function enqueue(cmd, args, quiet) {
queue.push({
cmd: cmd,
args: args || [],
quiet: !!quiet
quiet: !!quiet,
});
}

Expand All @@ -57,8 +57,8 @@ function flush() {
stdio: [
process.stdin,
entry.quiet ? "ignore" : process.stdout,
process.stderr
]
process.stderr,
],
}).on("exit", asyncCallback);
}
}
Expand Down Expand Up @@ -86,55 +86,47 @@ function makeMochaCopyFunction(fileName) {
if (semver.gte(process.version, "0.11.2")) {
enqueue("mocha", [
"--harmony",
"--reporter", "spec",
"--require", "./test/runtime.js",
"--reporter",
"spec",
"--require",
"./test/runtime.js",
"./test/tests.es6.js",
]);
}

if (semver.gte(process.version, "4.0.0")) {
enqueue("mocha", [
"--harmony",
"--reporter", "spec",
"--require", "./test/runtime.js",
"--reporter",
"spec",
"--require",
"./test/runtime.js",
"./test/tests-node4.es6.js",
]);
}

enqueue(convert, [
"./test/tests.es6.js",
"./test/tests.es5.js"
]);
enqueue(convert, ["./test/tests.es6.js", "./test/tests.es5.js"]);

if (semver.gte(process.version, "4.0.0")) {
enqueue(convert, [
"./test/tests-node4.es6.js",
"./test/tests-node4.es5.js"
]);
enqueue(convert, ["./test/tests-node4.es6.js", "./test/tests-node4.es5.js"]);
} else {
// we are on an older platform, but we still need to create an empty
// tests-node4.es5.js file so that the test commands below have a file to refer
// to.
fs.writeFileSync("./test/tests-node4.es5.js", "");
}

enqueue(convert, [
"./test/non-native.js",
"./test/non-native.es5.js"
]);
enqueue(convert, ["./test/non-native.js", "./test/non-native.es5.js"]);

enqueue(convert, [
"./test/async.js",
"./test/async.es5.js"
]);
enqueue(convert, ["./test/async.js", "./test/async.es5.js"]);

function convertWithSpread(es6File, es5File, callback) {
var transformOptions = {
presets:[require("regenerator-preset")],
presets: [require("regenerator-preset")],
plugins: [
require("babel-plugin-transform-es2015-spread"),
require("babel-plugin-transform-es2015-parameters")
]
require("babel-plugin-transform-es2015-parameters"),
],
};

fs.readFile(es6File, "utf-8", function(err, es6) {
Expand All @@ -150,7 +142,7 @@ function convertWithSpread(es6File, es5File, callback) {

enqueue(convertWithSpread, [
"./test/regression.js",
"./test/regression.es5.js"
"./test/regression.es5.js",
]);

enqueue(makeMochaCopyFunction("mocha.js"));
Expand All @@ -168,93 +160,95 @@ if (!semver.eq(process.version, "0.11.7")) {
"./test/tests-node4.es5.js",
"./test/non-native.es5.js",
"./test/async.es5.js",
"./test/regression.es5.js"
"./test/regression.es5.js",
],
"./test/tests.browser.js"
"./test/tests.browser.js",
]);
} catch (ignored) {
console.error("browserify not installed; skipping bundle step");
}
}

enqueue("mocha", [
"--reporter", "spec",
"--require", "./test/runtime.js",
"--reporter",
"spec",
"--require",
"./test/runtime.js",
"./test/tests.es5.js",
"./test/tests-node4.es5.js",
"./test/non-native.es5.js",
"./test/async.es5.js",
"./test/regression.es5.js",
"./test/tests.transform.js"
"./test/tests.transform.js",
]);

// Run command-line tool with available options to make sure it works.

enqueue("./bin/regenerator", [
"./test/async.es5.js"
], true);
enqueue("./bin/regenerator.js", ["./test/async.es5.js"], true);

enqueue("./bin/regenerator", [
"--include-runtime",
"./test/async.es5.js"
], true);
enqueue(
"./bin/regenerator.js",
["--include-runtime", "./test/async.es5.js"],
true
);

enqueue("./bin/regenerator", [
"--disable-async",
"./test/async.es5.js"
], true);
enqueue(
"./bin/regenerator.js",
["--disable-async", "./test/async.es5.js"],
true
);

enqueue("./bin/regenerator", [
"--include-runtime",
"--disable-async",
"./test/async.es5.js"
], true);
enqueue(
"./bin/regenerator.js",
["--include-runtime", "--disable-async", "./test/async.es5.js"],
true
);

// Make sure we run the command-line tool on a file that does not need any
// transformation, too.

enqueue("./bin/regenerator", [
"./test/nothing-to-transform.js"
], true);
enqueue("./bin/regenerator.js", ["./test/nothing-to-transform.js"], true);

enqueue("./bin/regenerator", [
"--include-runtime",
"./test/nothing-to-transform.js"
], true);
enqueue(
"./bin/regenerator.js",
["--include-runtime", "./test/nothing-to-transform.js"],
true
);

enqueue("./bin/regenerator", [
"--disable-async",
"./test/nothing-to-transform.js"
], true);
enqueue(
"./bin/regenerator.js",
["--disable-async", "./test/nothing-to-transform.js"],
true
);

enqueue("./bin/regenerator", [
"--include-runtime",
"--disable-async",
"./test/nothing-to-transform.js"
], true);
enqueue(
"./bin/regenerator.js",
["--include-runtime", "--disable-async", "./test/nothing-to-transform.js"],
true
);

// Make sure we run the command-line tool on a file that would trigger this error:
//
// You passed `path.replaceWith()` a falsy node, use `path.remove()` instead

enqueue("./bin/regenerator", [
"./test/replaceWith-falsy.js"
], true);

enqueue("./bin/regenerator", [
"--include-runtime",
"./test/replaceWith-falsy.js"
], true);

enqueue("./bin/regenerator", [
"--disable-async",
"./test/replaceWith-falsy.js"
], true);

enqueue("./bin/regenerator", [
"--include-runtime",
"--disable-async",
"./test/replaceWith-falsy.js"
], true);
enqueue("./bin/regenerator.js", ["./test/replaceWith-falsy.js"], true);

enqueue(
"./bin/regenerator.js",
["--include-runtime", "./test/replaceWith-falsy.js"],
true
);

enqueue(
"./bin/regenerator.js",
["--disable-async", "./test/replaceWith-falsy.js"],
true
);

enqueue(
"./bin/regenerator.js",
["--include-runtime", "--disable-async", "./test/replaceWith-falsy.js"],
true
);

flush();

0 comments on commit 9d927ae

Please sign in to comment.