Skip to content

Commit

Permalink
Change error to stdout, add option to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Jahn committed Jan 9, 2016
1 parent 8f40749 commit da1387f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -36,6 +36,7 @@ npm install -g updtr
-w, --wanted updates to wanted version specified in package.json instead of the modules latest version
-t, --test <test> change the command for the tests
-e, --exclude <exclude> exclude modules comma seperated, e.g. updtr --exclude module1,module2
--test-stdout shows stdout if your test command fails
```

## License
Expand Down
4 changes: 2 additions & 2 deletions bin/updtr
Expand Up @@ -12,7 +12,7 @@ program
.option("-w, --wanted", "updates to wanted version specified in package.json instead of the modules latest version")
.option("-t, --test <test>", "change the command for the tests")
.option("-e, --exclude <exclude>", "exclude modules comma seperated, e.g. updtr --exclude module1,module2", "excludes")
.option("--test-errors", "shows stdout if your test command fails");
.option("--test-stdout", "shows stdout if your test command fails");

program.parse(process.argv);

Expand All @@ -28,7 +28,7 @@ updtr.run({
wanted: program.wanted,
testCmd: program.test,
exclude: program.exclude,
testErrors: program.testErrors
testStdout: program.testStdout
}, function (err) {
if (err) {
throw err;
Expand Down
4 changes: 2 additions & 2 deletions lib/reporters/default.js
Expand Up @@ -83,8 +83,8 @@ function defaultReporter(emitter) {
logUpdateProgress(event, "error", info.updateTo + " failed".grey);
finishProgress();
});
emitter.on("testErrors", function (event) {
console.log(event.errors);
emitter.on("testStdout", function (event) {
console.log(event.testStdout);
});
emitter.on("updatingDone", function (event) {
var info = event.info;
Expand Down
6 changes: 3 additions & 3 deletions lib/run.js
Expand Up @@ -76,9 +76,9 @@ function run(config, done) {
return;
}
emitter.emit("rollbackDone", event);
if (config.testErrors) {
event.errors = testStdout;
emitter.emit("testErrors", event);
if (config.testStdout) {
event.testStdout = testStdout;
emitter.emit("testStdout", event);
}
done();
});
Expand Down
9 changes: 4 additions & 5 deletions test/run.js
Expand Up @@ -231,7 +231,6 @@ function execMock(object, testsExpectToPass) {
if (cmd === "npm outdated --json --long --depth=0") {
setImmediate(cb, null, JSON.stringify(object), null);
} else if (cmd === "npm test" && !testsExpectToPass) {
console.log("PASS");
setImmediate(cb, new Error("test failed"), "This is the test error stdout", "This is the test error stderr");
} else {
setImmediate(cb, null);
Expand Down Expand Up @@ -523,19 +522,19 @@ describe("run()", function () {
});
});

describe.only("testErrors", function () {
describe("if --test-errors is set and update fails", function () {
describe("testStdout", function () {
describe("if --test-stdout is set and update fails", function () {
before(setupOutdatedModules(outdatedModules, false));
afterEach(tearDown);

it("should be emitted", function (done) {
reporter = function (emitter) {
emitter.on("testErrors", function (options) {
emitter.on("testStdout", function (options) {
expect(options).to.eql(expectedOptionsWithCurrentCountLatestAndTestErrors);
});
};

run({ cwd: process.cwd(), reporter: reporter, testErrors: true }, done);
run({ cwd: process.cwd(), reporter: reporter, testStdout: true }, done);
});
});
});
Expand Down

0 comments on commit da1387f

Please sign in to comment.