-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pnpm as optional package manager (#1020)
- Loading branch information
1 parent
eae7346
commit 46d35ae
Showing
17 changed files
with
360 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { tmpdir } from 'os'; | ||
import { promises as fs } from 'fs'; | ||
import { join, dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
import tap from 'tap'; | ||
|
||
import { getPackageManagers } from '../../lib/package-manager/index.js'; | ||
import packageManagerInstall from '../../lib/package-manager/install.js'; | ||
import { npmContext } from '../helpers/make-context.js'; | ||
|
||
const { test } = tap; | ||
|
||
const sandbox = join(tmpdir(), `citgm-${Date.now()}-pnpm-install`); | ||
const fixtures = join( | ||
dirname(fileURLToPath(import.meta.url)), | ||
'..', | ||
'fixtures' | ||
); | ||
const moduleFixtures = join(fixtures, 'omg-i-pass'); | ||
const moduleTemp = join(sandbox, 'omg-i-pass'); | ||
const extraParamFixtures = join(fixtures, 'omg-i-pass-with-install-param'); | ||
const extraParamTemp = join(sandbox, 'omg-i-pass-with-install-param'); | ||
const badFixtures = join(fixtures, 'omg-bad-tree'); | ||
const badTemp = join(sandbox, 'omg-bad-tree'); | ||
|
||
let packageManagers; | ||
|
||
test('pnpm-install: setup', async () => { | ||
packageManagers = await getPackageManagers(); | ||
await fs.mkdir(sandbox, { recursive: true }); | ||
await Promise.all([ | ||
fs.cp(moduleFixtures, moduleTemp, { recursive: true }), | ||
fs.cp(extraParamFixtures, extraParamTemp, { recursive: true }), | ||
fs.cp(badFixtures, badTemp, { recursive: true }) | ||
]); | ||
}); | ||
|
||
test('pnpm-install: basic module', async () => { | ||
const context = npmContext('omg-i-pass', packageManagers, sandbox); | ||
await packageManagerInstall('pnpm', context); | ||
}); | ||
|
||
test('pnpm-install: no package.json', async (t) => { | ||
t.plan(2); | ||
const context = npmContext('omg-i-fail', packageManagers, sandbox); | ||
try { | ||
await packageManagerInstall('pnpm', context); | ||
} catch (err) { | ||
t.equal(err && err.message, 'Install Failed'); | ||
t.notOk(context.module.flaky, 'Module failed but is not flaky'); | ||
} | ||
}); | ||
|
||
test('pnpm-install: timeout', async (t) => { | ||
t.plan(2); | ||
const context = npmContext('omg-i-pass', packageManagers, sandbox, { | ||
timeout: 10 | ||
}); | ||
try { | ||
await packageManagerInstall('pnpm', context); | ||
} catch (err) { | ||
t.notOk(context.module.flaky, 'Time out should not mark module flaky'); | ||
t.equal(err && err.message, 'Install Timed Out'); | ||
} | ||
}); | ||
|
||
test('pnpm-install: failed install', async (t) => { | ||
t.plan(3); | ||
const context = npmContext('omg-bad-tree', packageManagers, sandbox); | ||
const expected = /\/THIS-WILL-FAIL: Not Found/; | ||
try { | ||
await packageManagerInstall('pnpm', context); | ||
} catch (err) { | ||
t.notOk(context.module.flaky, 'Module failed is not flaky'); | ||
t.equal(err && err.message, 'Install Failed'); | ||
t.match(context.testError.toString(), expected, 'Install error reported'); | ||
} | ||
}); | ||
|
||
tap.teardown(async () => { | ||
await fs.rm(sandbox, { | ||
recursive: true, | ||
force: true, | ||
maxRetries: 10, | ||
retryDelay: 10 | ||
}); | ||
}); |
Oops, something went wrong.