Browse Source

Merge pull request #66 from zeit/add/version-reporting

index: add version reporting, support for `engines`
master
Tony Kovanen 9 years ago
parent
commit
75d9723d76
  1. 16
      lib/index.js

16
lib/index.js

@ -72,7 +72,7 @@ export default class Now extends EventEmitter {
this._files = hashes;
const nowProperties = pkg.now || {};
const engines = nowProperties.engines;
const engines = nowProperties.engines || pkg.engines;
const deployment = await retry(async (bail) => {
if (this._debug) console.time('> [debug] /now/create');
@ -115,6 +115,7 @@ export default class Now extends EventEmitter {
}, { retries: 3, minTimeout: 2500, onRetry: this._onRetry });
// we report about files whose sizes are too big
let missingVersion = false;
if (deployment.warnings) {
let sizeExceeded = 0;
deployment.warnings.forEach((warning) => {
@ -129,10 +130,11 @@ export default class Now extends EventEmitter {
sizeExceeded++;
} else if ('node_version_not_found' === warning.reason) {
const { wanted, used } = warning;
console.error('> \u001b[31mWarning!\u001b[39m Requested node version %s is not available, using default version %s',
console.error('> \u001b[31mWarning!\u001b[39m Requested node version %s is not available',
wanted,
used
);
missingVersion = true;
}
});
@ -143,6 +145,16 @@ export default class Now extends EventEmitter {
}
}
if (engines.node) {
if (missingVersion) {
console.log(`> Using Node.js ${chalk.bold(deployment.nodeVersion)} (default)`);
} else {
console.log(`> Using Node.js ${chalk.bold(deployment.nodeVersion)} (requested: ${chalk.dim(`\`${engines.node}\``)})`);
}
} else {
console.log(`> Using Node.js ${chalk.bold(deployment.nodeVersion)} (default)`);
}
this._id = deployment.deploymentId;
this._host = deployment.url;
this._missing = deployment.missing || [];

Loading…
Cancel
Save