Skip to content
Open
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
16 changes: 16 additions & 0 deletions packages/cli/src/commands/init/__tests__/init.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import initialize from '../init';
import * as npm from '../../../tools/npm';
import * as yarn from '../../../tools/yarn';

afterEach(() => {
jest.restoreAllMocks();
});

test('rejects when the requested package manager is unavailable', async () => {
jest.spyOn(npm, 'npmResolveConcreteVersion').mockResolvedValue('0.76.0');
jest.spyOn(yarn, 'getYarnVersionIfAvailable').mockReturnValue(null);

await expect(initialize(['TestApp'], {pm: 'yarn'})).rejects.toThrowError(
'Seems like the package manager you want to use is not installed.',
);
});
3 changes: 1 addition & 2 deletions packages/cli/src/commands/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,9 @@ export default (async function initialize(
const projectFolder = path.join(root, directoryName);

if (options.pm && !checkPackageManagerAvailability(options.pm)) {
logger.error(
throw new CLIError(
'Seems like the package manager you want to use is not installed. Please install it or choose another package manager.',
);
return;
}

let shouldBumpYarnVersion = true;
Expand Down
Loading