@firefoxic/utils 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ import { env } from "node:process"
2
+
3
+ /**
4
+ * Get the path to the project root when deploying to GitHub Pages.
5
+ * Your action should set `REPO_NAME` and `REPO_NAME` environment variables at the step you need
6
+ * (most likely when building the project), for example like this:
7
+ *
8
+ * - name: Build project
9
+ * run: pnpm build
10
+ * env:
11
+ * REPO_NAME: ${{ github.event.repository.name }}
12
+ * PR_NUMBER: ${{ github.event.pull_request.number }}
13
+ *
14
+ * @returns {string} The path to the project directory from the domain root if working in a GitHub CI environment. If not, returns `/`.
15
+ */
16
+ export function getProjectRoot () {
17
+ if (!env.CI || !env.REPO_NAME) { return `` }
18
+
19
+ if (!env.PR_NUMBER) { return `/${env.REPO_NAME}` }
20
+
21
+ return `/${env.REPO_NAME}/${env.PR_NUMBER}`
22
+ }
package/lib/index.js CHANGED
@@ -1 +1,3 @@
1
+ export { getProjectRoot } from "./getProjectRoot.js"
2
+
1
3
  export { updateChangelog } from "./updateChangelog.js"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firefoxic/utils",
3
3
  "description": "Collection of useful utilities for JavaScript and Node.js.",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Sergey Artemov",