Files
pnpm/exec/plugin-commands-script-runners/test/shouldRunCheck.test.ts
Khải 19d5b51558 feat(exec): check dependencies before running scripts (#8645)
* refactor: break a long line into multiple lines

* feat: cache that tracks workspace structures

* feat: handle hash collisions

* docs(changeset): packages-list-cache

* feat(packages-list-cache): store mtime

* fix(packages-list-cache): JSON5 and YAML manifests

* feat(packages-list-cache): add catalogs

* style: sort fields alphabetically

* fix: actually fix it

* lint: fix

* lint: fix

* test(packages-list-cache): test

* feat(exec): check deps before run scripts

Resolves https://github.com/pnpm/pnpm/issues/8585

* style: fix eslint

* feat: use a single lastValidatedTimestamp

* refactor: rearrange

* perf: don't do pointless comparisons

* perf: optimize non-workspace

* perf: optimize sharedWorkspaceLockfile=false

* perf: remove unnecessary fs reads

* refactor: statManifestFile

* perf: skip comparing manifest to lockfile by stats

* feat: add wantedLockfileDir to error message

* refactor: shorten a function name

* refactor: rename a function

* docs: improve wordings

* feat: export `linkedPackagesAreUpToDate`

* feat: make sure lockfile specs satisfy manifest (wip)

* docs: todo

* fix: projectId

* feat: skip install-related scripts

* fix: type errors

* refactor: use tagged union

* refactor: remove unnecessary type expression

* docs: todo

* feat: add linkedPackagesAreUpToDate (wip)

* refactor: rearrange fields

* refactor: remove a temporary variable

* feat: export `getWorkspacePackagesByDirectory`

* feat: make workspacePackages optional

* feat: complete `linkedPackagesAreUpToDate`

* docs: remove unapplicable todo

* docs: explain why check is skipped

* feat: load allProjects and try again

* refactor: remove unused dependencies

* refactor: remove commented-out code

* refactor: replace `else if` with `return`

* feat: use-case without workspace manifest

* perf: skip unnecessary work

* feat: add a guard

* fix: eslint

* refactor: move code to new package

* refactor: sort dependencies

* test: outline

* refactor: extract assertLockfilesEqual for testing

* test: skip failing tests for now

* fix: eslint

* test: assertLockfilesEqual

* refactor: extract statManifestFile for testing

* test: todo

* test: statManifestFile

* test: shouldRunCheck

* refactor: rename a test file

* test: add

* test: todo

* docs: remove a commented-out code

* test: create groups

* test: todo

* test: add

* test: platform agnostic

* test: remove unnecessary scripts

* test: use `assert.strictEqual` instead

* test: export bin locations

* test: nested `pnpm run`

* test: todo

* test: add `cwd` option to `execPnpmSync`

* test: add

* fix: recursive

* test: add

* test: fix package names

* fix: catalogs comparison

* test: add

* refactor: just use ramda filter

* test: add

* test: mutations

* fix: package.json

* fix: jest

* feat(packages-list): debug logs

* feat: add debug messages

* fix: eslint

* test: check debug messages in other case

* docs: add next step

* test: mtime updates without modification

* docs: correct test description

* test: mtime changes

* test: check should be skipped

* docs: remove fulfilled todos

* fix: remove `.only`

* docs: todo

* docs: correct test names

* test: workspace structure changes

* test: packages list cache

* test: add

* refactor: divide a test file into 2

* docs: consistent wordings

* refactor: clearer error messages

* fix: ignore check in recursive nested scripts

* test: no dependencies

* test: print error messages on failures

* test: improve stdout/stderr in error messages

* docs: consistent wordings

* docs: clarify what did what

* test: nested script

* docs: consistent test descriptions

* docs(changeset): correction

* fix: save catalogs to packages list

* test: catalogs

* test: fix

* test: fix windows

* refactor: remove unused option field

* refactor: prefer `!= null`

* feat: use `node_modules` instead

* refactor: rename a package

* refactor: apply suggestion

* refactor: remove workspaceDir

* refactor: move `shouldRunCheck` to `exec`

* feat: rename config key

* refactor: rename a test dir

* refactor: correct grammar

* refactor: make loadPackagesList sync

* test: multiple lockfiles

* feat: prevent deletion of `node_modules`

* feat: skip checking on filtered install

* fix: accidentally dropping catalogs

* refactor: remove unnecessary `Promise.all`

* refactor: use `virtualStoreDir` from config

* refactor: split `opts` into `ctx` and `opts`

* test: fix

* style: fix eslint

* test: fix windows

* feat(exec): add `verifyDepsBeforeRun` to `exec`

* refactor: sync stat

* feat: stop ignoring filtered install

* test: filtered install

* refactor: rearrange imports

* feat: rename "packages list" to "workspace state"

* test: fix

* fix: workspace state on failed install
2024-11-15 01:01:09 +01:00

21 lines
595 B
TypeScript

import { DISABLE_DEPS_CHECK_ENV, shouldRunCheck } from '../src/shouldRunCheck'
test('should return true if skip env is not defined and script name is not special', () => {
expect(shouldRunCheck({}, 'start')).toBe(true)
})
test('should return false if skip env is defined', () => {
expect(shouldRunCheck({ ...DISABLE_DEPS_CHECK_ENV }, 'start')).toBe(false)
})
test.each([
'preinstall',
'install',
'postinstall',
'preuninstall',
'uninstall',
'postuninstall',
])('should return false if script name is %p', scriptName => {
expect(shouldRunCheck({}, scriptName)).toBe(false)
})