@foray1010/common-presets-utils 5.0.1 → 5.0.3

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.0.3](https://github.com/foray1010/common-presets/compare/@foray1010/common-presets-utils@5.0.2...@foray1010/common-presets-utils@5.0.3) (2022-09-22)
7
+
8
+ **Note:** Version bump only for package @foray1010/common-presets-utils
9
+
10
+ ## [5.0.2](https://github.com/foray1010/common-presets/compare/@foray1010/common-presets-utils@5.0.1...@foray1010/common-presets-utils@5.0.2) (2022-08-24)
11
+
12
+ **Note:** Version bump only for package @foray1010/common-presets-utils
13
+
6
14
  ## [5.0.1](https://github.com/foray1010/common-presets/compare/@foray1010/common-presets-utils@5.0.0...@foray1010/common-presets-utils@5.0.1) (2022-06-13)
7
15
 
8
16
  ### Bug Fixes
package/index.js CHANGED
@@ -3,16 +3,22 @@
3
3
  const path = require('path')
4
4
  const readPkgUp = require('read-pkg-up')
5
5
 
6
- const { packageJson: pkg, path: pkgPath } = readPkgUp.sync()
6
+ const { packageJson: pkg, path: pkgPath } = readPkgUp.sync() ?? {}
7
7
 
8
- const pkgDir = path.dirname(pkgPath)
8
+ const pkgDir = pkgPath ? path.dirname(pkgPath) : undefined
9
9
 
10
+ /**
11
+ * Check if current application has a package as dependencies/devDependencies/peerDependencies
12
+ *
13
+ * @param {string} packageName package name in registry
14
+ * @returns {boolean} whether current application has this package as dependencies/devDependencies/peerDependencies or not
15
+ */
10
16
  const hasDep = (packageName) =>
11
- [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies]
12
- .flatMap((dependencies) => Object.keys(dependencies || {}))
17
+ [pkg?.dependencies, pkg?.devDependencies, pkg?.peerDependencies]
18
+ .flatMap((dependencies) => Object.keys(dependencies ?? {}))
13
19
  .includes(packageName)
14
20
 
15
- const isESM = () => pkg.type === 'module'
21
+ const isESM = () => pkg?.type === 'module'
16
22
 
17
23
  module.exports = {
18
24
  hasDep,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@foray1010/common-presets-utils",
4
- "version": "5.0.1",
4
+ "version": "5.0.3",
5
5
  "homepage": "https://github.com/foray1010/common-presets/tree/master/packages/common-presets-utils#readme",
6
6
  "bugs": "https://github.com/foray1010/common-presets/issues",
7
7
  "repository": {
@@ -15,14 +15,20 @@
15
15
  "**/*.{cjs,js,json,mjs}",
16
16
  "*.md"
17
17
  ],
18
+ "scripts": {
19
+ "type:check": "tsc"
20
+ },
18
21
  "dependencies": {
19
22
  "read-pkg-up": "^7.0.1"
20
23
  },
24
+ "devDependencies": {
25
+ "typescript": "4.8.3"
26
+ },
21
27
  "engines": {
22
28
  "node": "^14.17.0 || ^16.13.0 || >=18.0.0"
23
29
  },
24
30
  "publishConfig": {
25
31
  "access": "public"
26
32
  },
27
- "gitHead": "162f905054a12ba6777eb746f2f440a68876463c"
33
+ "gitHead": "73bd0116236620e7171c9e7c5442afa50bcfbed7"
28
34
  }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "@foray1010/tsconfig",
4
+ "compilerOptions": {
5
+ "allowJs": true,
6
+ "checkJs": true
7
+ }
8
+ }