Skip to content

Commit

Permalink
Merge pull request #2403 from chamsou123/issue-2400-patch
Browse files Browse the repository at this point in the history
refactor: Implement osName, remove os-name package
  • Loading branch information
kamilmysliwiec committed Jan 8, 2024
2 parents 31bfda2 + ab55b2d commit c3cfc0d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 119 deletions.
4 changes: 2 additions & 2 deletions actions/info.action.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as chalk from 'chalk';
import { readFileSync } from 'fs';
import { platform, release } from 'os';
import osName = require('os-name');
import { join } from 'path';
import {
AbstractPackageManager,
PackageManagerFactory,
} from '../lib/package-managers';
import { BANNER, MESSAGES } from '../lib/ui';
import { AbstractAction } from './abstract.action';
import osName from '../lib/utils/os-info.utils';

interface LockfileDependency {
version: string;
Expand Down Expand Up @@ -39,7 +39,7 @@ export class InfoAction extends AbstractAction {

private async displaySystemInformation(): Promise<void> {
console.info(chalk.green('[System Information]'));
console.info('OS Version :', chalk.blue(osName(platform(), release())));
console.info('OS Version :', chalk.blue(osName(platform(), release()), release()));
console.info('NodeJS Version :', chalk.blue(process.version));
await this.displayPackageManagerVersion();
}
Expand Down
20 changes: 20 additions & 0 deletions lib/utils/os-info.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default function osName(platform: string, release: string): string {
switch (platform) {
case 'darwin':
return Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X';
case 'linux':
return 'Linux';
case 'win32':
return 'Windows';
case 'freebsd':
return 'FreeBSD';
case 'openbsd':
return 'OpenBSD';
case 'sunos':
return 'Solaris';
case 'android':
return 'Android';
default:
return platform;
}
}
130 changes: 14 additions & 116 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"inquirer": "8.2.6",
"node-emoji": "1.11.0",
"ora": "5.4.1",
"os-name": "4.0.1",
"rimraf": "4.4.1",
"shelljs": "0.8.5",
"source-map-support": "0.5.21",
Expand Down

0 comments on commit c3cfc0d

Please sign in to comment.