Skip to content

Commit

Permalink
Print only the url when being piped/scripted. (#65)
Browse files Browse the repository at this point in the history
Print only the url when being piped/scripted.
  • Loading branch information
rwjblue authored May 16, 2019
2 parents da4d191 + 569cd10 commit aaaa70a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bin/ember-source-channel-url
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ if (['release', 'beta', 'canary'].indexOf(channel) === -1) {
process.exitCode = 1;
} else {
getChannelURL(channel).then(url => {
console.log(
`The URL for the latest tarball from ember-source's ${channel} channel is:\n\n\t${url}\n`
);
if (process.stdout.isTTY) {
console.log(
`The URL for the latest tarball from ember-source's ${channel} channel is:\n\n\t${url}\n`
);
} else {
process.stdout.write(url);
}

if (shouldUpdatePackage) {
if (!fs.existsSync('package.json')) {
Expand Down
11 changes: 11 additions & 0 deletions tests/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ QUnit.module('ember-source-channel-url', function(hooks) {
});
});

QUnit.test('when the terminal is not a TTY return only the URL', function(assert) {
let file = tmp.fileSync();
return execa(EXECUTABLE_PATH, ['canary'], { stdout: file.fd }).then(() => {
assert.equal(
fs.readFileSync(file.name, { encoding: 'utf8' }),
this.expectedURL,
'stdout is the URL'
);
});
});

QUnit.test('updates local package.json when -w is passed (dependencies)', function(assert) {
fs.writeFileSync(
'package.json',
Expand Down

0 comments on commit aaaa70a

Please sign in to comment.