mirror of
https://github.com/strapi/strapi.git
synced 2025-09-27 01:09:49 +00:00
Merge pull request #13950 from strapi/fix/ts-get-config-path-invalid-return-type
Fix invalid return for ts get-config-path
This commit is contained in:
commit
0f7d51a996
@ -5,6 +5,16 @@ const ts = require('typescript');
|
|||||||
|
|
||||||
const DEFAULT_TS_CONFIG_FILENAME = 'tsconfig.json';
|
const DEFAULT_TS_CONFIG_FILENAME = 'tsconfig.json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path of the typescript config file for a given directory
|
||||||
|
*
|
||||||
|
* @param {string} dir
|
||||||
|
* @param {object} [options]
|
||||||
|
* @param {string} [options.filename]
|
||||||
|
* @param {boolean} [options.ancestorsLookup]
|
||||||
|
*
|
||||||
|
* @return {string | undefined}
|
||||||
|
*/
|
||||||
module.exports = (dir, { filename = DEFAULT_TS_CONFIG_FILENAME, ancestorsLookup = false } = {}) => {
|
module.exports = (dir, { filename = DEFAULT_TS_CONFIG_FILENAME, ancestorsLookup = false } = {}) => {
|
||||||
const dirAbsolutePath = path.resolve(dir);
|
const dirAbsolutePath = path.resolve(dir);
|
||||||
const configFilePath = ts.findConfigFile(dirAbsolutePath, ts.sys.fileExists, filename);
|
const configFilePath = ts.findConfigFile(dirAbsolutePath, ts.sys.fileExists, filename);
|
||||||
@ -13,5 +23,5 @@ module.exports = (dir, { filename = DEFAULT_TS_CONFIG_FILENAME, ancestorsLookup
|
|||||||
return configFilePath;
|
return configFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return configFilePath.startsWith(dirAbsolutePath);
|
return configFilePath.startsWith(dirAbsolutePath) ? configFilePath : undefined;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user