Skip to content

Tags: angular-schule/angular-cli-ghpages

Tags

v3.0.3

Toggle v3.0.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix: set CACHE_DIR fallback when no package.json is reachable (#203) (#…

…208)

* fix: set CACHE_DIR fallback when no package.json is reachable

gh-pages@6.3.0 calls find-cache-dir({ name: 'gh-pages' }) for both
clean() and publish(). find-cache-dir walks up from cwd looking for a
package.json and returns undefined when it finds none. gh-pages then
does path.join(undefined, ...) and throws:

  The "path" argument must be of type string or an instance of Buffer
  or URL. Received undefined

This hit users running `npx angular-cli-ghpages` from a repo that is
just a dist/ folder (no package.json). The reporter's workaround of
`npm install angular-cli-ghpages` first worked because it created a
package.json that find-cache-dir could find.

Fix: add ensureGhPagesCacheDir() to engine.prepare-options-helpers and
call it from engine.run() before gh-pages is required. If no
package.json is reachable from cwd, we set process.env.CACHE_DIR to
`<os.tmpdir()>/angular-cli-ghpages-cache`. find-cache-dir honors
CACHE_DIR as an explicit override — when set (and not a boolean-ish
value 'true'/'false'/'1'/'0') it short-circuits its package.json walk.

We do the package.json probe ourselves rather than delegating to
find-cache-dir: find-cache-dir captures `const {env} = process` at
module load and is then cached in require.cache, which makes it
brittle under test reassignment of process.env.

Tests:

- engine.prepare-options-helpers.spec.ts — unit tests covering: cwd
  with no package.json sets fallback; cwd with package.json is a
  no-op; pre-existing user-set CACHE_DIR is preserved; boolean-ish
  CACHE_DIR values ('true'/'false'/etc.) are treated as unset per
  find-cache-dir's own semantics; fallback path is deterministically
  inside os.tmpdir().

- engine.gh-pages-no-package-json.spec.ts — real-git, real-gh-pages
  end-to-end. Creates a bare repo + workdir with no package.json in
  any ancestor, process.chdir()s there, runs engine.run(), inspects
  the remote tree, asserts the dist actually lands. A companion
  baseline test spawns a child Node process (no shared require.cache)
  and calls bare gh-pages.clean() in the same workdir, asserting it
  throws the original TypeError — proving the upstream bug is real.

Fixes #203

* chore: keep version at 3.0.3 until all fixes are released together

We don't ship a new npm version per fix; all pending fixes (#204, #205,
#203, and follow-ups) will be released in a single bump at release
time. This also rolls back the earlier per-PR bump that landed on main.

v3.0.2

Toggle v3.0.2's commit message

v3.0.1

Toggle v3.0.1's commit message

v3.0.0

Toggle v3.0.0's commit message

v2.0.3

Toggle v2.0.3's commit message

v2.0.2

Toggle v2.0.2's commit message

v2.0.1

Toggle v2.0.1's commit message

v2.0.0

Toggle v2.0.0's commit message

v2.0.0-beta.1

Toggle v2.0.0-beta.1's commit message

v1.0.6

Toggle v1.0.6's commit message