Skip to content

Commit

Permalink
logs: check if deployment url includes path
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzawa authored and leo committed May 2, 2017
1 parent 2a25bfc commit eb48779
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions bin/now-logs.js
Expand Up @@ -88,7 +88,12 @@ try {
}

if (maybeURL(deploymentIdOrURL)) {
deploymentIdOrURL = normalizeURL(deploymentIdOrURL);
const normalizedURL = normalizeURL(deploymentIdOrURL);
if (normalizedURL.includes('/')) {
error(`Invalid deployment url: can't include path (${deploymentIdOrURL})`);
process.exit(1);
}
deploymentIdOrURL = normalizedURL;
}

Promise.resolve()
Expand All @@ -103,20 +108,20 @@ Promise.resolve()
process.exit(1);
}

await printLogs({token, config});
await printLogs({ token, config });
})
.catch(err => {
error(`Unknown error: ${err.stack}`);
process.exit(1);
});

async function printLogs({token, config: {currentTeam}}) {
async function printLogs({ token, config: { currentTeam } }) {
let buf = [];
let init = false;
let lastLog;

if (!follow) {
onLogs(await fetchLogs({token, currentTeam, since, until }));
onLogs(await fetchLogs({ token, currentTeam, since, until }));
return;
}

Expand Down Expand Up @@ -150,7 +155,7 @@ async function printLogs({token, config: {currentTeam}}) {
// For the case socket reconnected
const _since = lastLog ? lastLog.serial : since;

fetchLogs({token, currentTeam, since: _since }).then(logs => {
fetchLogs({ token, currentTeam, since: _since }).then(logs => {
init = true;
const m = {};
logs.concat(buf.map(b => b.log)).forEach(l => {
Expand Down Expand Up @@ -232,8 +237,8 @@ function printLog(log) {
});
}

async function fetchLogs({token, currentTeam, since, until } = {}) {
const now = new Now({apiUrl, token, debug, currentTeam });
async function fetchLogs({ token, currentTeam, since, until } = {}) {
const now = new Now({ apiUrl, token, debug, currentTeam });

let logs;
try {
Expand Down

0 comments on commit eb48779

Please sign in to comment.