@strapi/typescript-utils 4.3.1 → 4.3.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.
@@ -1,9 +1,27 @@
1
1
  'use strict';
2
2
 
3
+ const path = require('path');
3
4
  const ts = require('typescript');
4
5
 
5
6
  const DEFAULT_TS_CONFIG_FILENAME = 'tsconfig.json';
6
7
 
7
- module.exports = (dir, filename = DEFAULT_TS_CONFIG_FILENAME) => {
8
- return ts.findConfigFile(dir, ts.sys.fileExists, filename);
8
+ /**
9
+ * Get the path of the typescript config file for a given directory
10
+ *
11
+ * @param {string} dir
12
+ * @param {object} [options]
13
+ * @param {string} [options.filename]
14
+ * @param {boolean} [options.ancestorsLookup]
15
+ *
16
+ * @return {string | undefined}
17
+ */
18
+ module.exports = (dir, { filename = DEFAULT_TS_CONFIG_FILENAME, ancestorsLookup = false } = {}) => {
19
+ const dirAbsolutePath = path.resolve(dir);
20
+ const configFilePath = ts.findConfigFile(dirAbsolutePath, ts.sys.fileExists, filename);
21
+
22
+ if (!configFilePath || ancestorsLookup) {
23
+ return configFilePath;
24
+ }
25
+
26
+ return configFilePath.startsWith(dirAbsolutePath) ? configFilePath : undefined;
9
27
  };
@@ -11,7 +11,7 @@ const getConfigPath = require('./get-config-path');
11
11
  * @returns {boolean}
12
12
  */
13
13
  module.exports = (dir, filename = undefined) => {
14
- const filePath = getConfigPath(dir, filename);
14
+ const filePath = getConfigPath(dir, { filename });
15
15
 
16
16
  return fse.pathExistsSync(filePath);
17
17
  };
@@ -11,7 +11,7 @@ const getConfigPath = require('./get-config-path');
11
11
  * @returns {Promise<boolean>}
12
12
  */
13
13
  module.exports = (dir, filename = undefined) => {
14
- const filePath = getConfigPath(dir, filename);
14
+ const filePath = getConfigPath(dir, { filename });
15
15
 
16
16
  return fse.pathExists(filePath);
17
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/typescript-utils",
3
- "version": "4.3.1",
3
+ "version": "4.3.3",
4
4
  "description": "Typescript support for Strapi",
5
5
  "keywords": [
6
6
  "strapi",
@@ -35,5 +35,5 @@
35
35
  "node": ">=12.22.0 <=16.x.x",
36
36
  "npm": ">=6.0.0"
37
37
  },
38
- "gitHead": "1eab2fb08c7a4d3d40a5a7ff3b2f137ce0afcf8a"
38
+ "gitHead": "4d60bfdeee6eb5e9b42b5a614690d7bb86c5f84a"
39
39
  }