Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,38 @@

const os = require('os');

const chalk = require('chalk');
const meow = require('meow');

const updateNotifier = require('update-notifier');

const pkg = require('../package.json');

const getUnityUrls = require('../lib/get-unity-urls');

const cli = meow(
`
Usage
$ get-unity <version> [options]

Options
${chalk.yellow('--help, -h')} Display this help message.
${chalk.yellow('--version, -v')} Display the current installed version.
`,
{
'flags': {
'autoHelp': true,
'autoVersion': true
}
}
);

const osKeyMap = {
'Darwin': 'mac',
'Windows_NT': 'win64'
};

const PROCESS_CMD_LINE_ARGS_LENGTH = 2;

const requestedVersion = process.argv.slice(PROCESS_CMD_LINE_ARGS_LENGTH).pop();

updateNotifier({pkg}).notify();

getUnityUrls(requestedVersion).then(urls =>
getUnityUrls(cli.input[0]).then(urls =>
process.stdout.write(`${urls[osKeyMap[os.type()]]}`));
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
},
"license": "MIT",
"dependencies": {
"chalk": "2.4.2",
"meow": "5.0.0",
"update-notifier": "3.0.1"
},
"devDependencies": {
Expand Down