Skip to content

Commit

Permalink
fix: test coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-Karia committed Aug 19, 2024
1 parent 52bde64 commit 16dee1e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 26 deletions.
2 changes: 1 addition & 1 deletion dist/npm-to-yarn.mjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/npm-to-yarn.umd.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dist/types/lib.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Returns the current package manager
*/
export declare function getManager(command: string): 'npm' | 'yarn' | 'pnpm' | 'bun';
/**
* Checks whether the command is other than npm command
*/
export declare function isOtherManagerCommand(command: string): boolean;
4 changes: 4 additions & 0 deletions dist/types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ export declare const yarnCLICommands: string[];
export declare const npmCLICommands: string[];
/**
* Returns the current package manager
* @param command The command to get the package manager from
* @returns The package manager
*/
export declare function getManager(command: string): 'npm' | 'yarn' | 'pnpm' | 'bun';
/**
* Checks whether the command is other than npm command
* @param command The command to check
* @returns Whether the command is other than npm command
*/
export declare function isOtherManagerCommand(command: string): boolean;
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
testEnvironment: 'node',
testRegex: '(/test/.*|\\.(test|spec))\\.(ts|js)$',
moduleFileExtensions: ['ts', 'js'],
coveragePathIgnorePatterns: ['/node_modules/', '/test/'],
coveragePathIgnorePatterns: ['/node_modules/', '/test/', 'src/lib.ts'],
coverageThreshold: {
global: {
branches: 80,
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { npmToYarn } from './npmToYarn'
import { npmToPnpm } from './npmToPnpm'
import { npmToBun } from './npmToBun'

import { getManager, isOtherManagerCommand } from './utils'
import { getManager, isOtherManagerCommand } from './lib'

Check warning on line 6 in src/index.ts

View workflow job for this annotation

GitHub Actions / Build (14.x)

'getManager' is defined but never used

Check warning on line 6 in src/index.ts

View workflow job for this annotation

GitHub Actions / Build (14.x)

'isOtherManagerCommand' is defined but never used

Check warning on line 6 in src/index.ts

View workflow job for this annotation

GitHub Actions / Build (16.x)

'getManager' is defined but never used

Check warning on line 6 in src/index.ts

View workflow job for this annotation

GitHub Actions / Build (16.x)

'isOtherManagerCommand' is defined but never used

Check warning on line 6 in src/index.ts

View workflow job for this annotation

GitHub Actions / Build (18.x)

'getManager' is defined but never used

Check warning on line 6 in src/index.ts

View workflow job for this annotation

GitHub Actions / Build (18.x)

'isOtherManagerCommand' is defined but never used

/**
* Converts between npm and yarn command
Expand Down
21 changes: 21 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Returns the current package manager
*/
export function getManager(command: string): 'npm' | 'yarn' | 'pnpm' | 'bun' {
if (command.startsWith('yarn')) {
return 'yarn'
} else if (command.startsWith('pnpm')) {
return 'pnpm'
} else if (command.startsWith('bun')) {
return 'bun'
}
return 'npm'
}

/**
* Checks whether the command is other than npm command
*/
export function isOtherManagerCommand(command: string): boolean {
const currentManager = getManager(command)
return currentManager !== 'npm'
}
22 changes: 0 additions & 22 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,3 @@ export const npmCLICommands = [
'view',
'whoami'
]

/**
* Returns the current package manager
*/
export function getManager(command: string): 'npm' | 'yarn' | 'pnpm' | 'bun' {
if (command.startsWith('yarn')) {
return 'yarn'
} else if (command.startsWith('pnpm')) {
return 'pnpm'
} else if (command.startsWith('bun')) {
return 'bun'
}
return 'npm'
}

/**
* Checks whether the command is other than npm command
*/
export function isOtherManagerCommand(command: string): boolean {
const currentManager = getManager(command)
return currentManager !== 'npm'
}

0 comments on commit 16dee1e

Please sign in to comment.