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
15 changes: 5 additions & 10 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env node

import os from 'os';

import chalk from 'chalk';

import meow from 'meow';
Expand All @@ -14,6 +12,7 @@ import {
EDITOR_INSTALLERS_FILE_PATH,
updateEditorInstallers,
} from '../lib/update-editor-installers.js';
import { getOperatingSystemKey } from '../lib/os.js';
import { getUnityUrls } from '../lib/get-unity-urls.js';
import { parseVersionFromString } from '../lib/parsers.js';

Expand Down Expand Up @@ -64,12 +63,6 @@ const cli = meow(
}
);

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

const DEFAULT_CACHE_TTL = 3600000;

updateNotifier({ pkg: (await readPackageUp()).packageJson }).notify();
Expand All @@ -84,10 +77,12 @@ if (cli.flags.file) {
}
}

const osKey = getOperatingSystemKey();

if (cli.flags.offline) {
const urls = await getUnityUrls(cli.input[0], EDITOR_INSTALLERS_FILE_PATH);

process.stdout.write(`${urls[osKeyMap[os.type()]]}`);
process.stdout.write(`${urls[osKey]}`);
} else {
try {
await updateEditorInstallers(
Expand All @@ -97,7 +92,7 @@ if (cli.flags.offline) {

const urls = await getUnityUrls(cli.input[0], EDITOR_INSTALLERS_FILE_PATH);

process.stdout.write(`${urls[osKeyMap[os.type()]]}`);
process.stdout.write(`${urls[osKey]}`);
} catch (error) {
process.stderr.write(`${chalk.red('Error:')} ${error.message}`);
}
Expand Down
Loading