mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Merge pull request #13937 from strapi/fix/ts-false-positive-get-config-path
Fix false positive results for ts utils' getConfigPath
This commit is contained in:
commit
f7a7098ef2
@ -1,9 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const ts = require('typescript');
|
||||
|
||||
const DEFAULT_TS_CONFIG_FILENAME = 'tsconfig.json';
|
||||
|
||||
module.exports = (dir, filename = DEFAULT_TS_CONFIG_FILENAME) => {
|
||||
return ts.findConfigFile(dir, ts.sys.fileExists, filename);
|
||||
module.exports = (dir, { filename = DEFAULT_TS_CONFIG_FILENAME, ancestorsLookup = false } = {}) => {
|
||||
const dirAbsolutePath = path.resolve(dir);
|
||||
const configFilePath = ts.findConfigFile(dirAbsolutePath, ts.sys.fileExists, filename);
|
||||
|
||||
if (!configFilePath || ancestorsLookup) {
|
||||
return configFilePath;
|
||||
}
|
||||
|
||||
return configFilePath.startsWith(dirAbsolutePath);
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ const getConfigPath = require('./get-config-path');
|
||||
* @returns {boolean}
|
||||
*/
|
||||
module.exports = (dir, filename = undefined) => {
|
||||
const filePath = getConfigPath(dir, filename);
|
||||
const filePath = getConfigPath(dir, { filename });
|
||||
|
||||
return fse.pathExistsSync(filePath);
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ const getConfigPath = require('./get-config-path');
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
module.exports = (dir, filename = undefined) => {
|
||||
const filePath = getConfigPath(dir, filename);
|
||||
const filePath = getConfigPath(dir, { filename });
|
||||
|
||||
return fse.pathExists(filePath);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user