Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print only the url when being piped/scripted. #65

Merged
merged 1 commit into from May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions bin/ember-source-channel-url
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
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