Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var dir = fs.lstatSync(pathOrSrcFile).isDirectory() ? pathOrSrcFile : path.dirname(pathOrSrcFile);
var projectFile = tsconfig.resolveSync(dir);
if (!projectFile) {
throw errorWithDetails(new Error(exports.errors.GET_PROJECT_NO_PROJECT_FOUND), { projectFilePath: fsu.consistentPath(pathOrSrcFile), errorMessage: 'not found' });
}
var projectFileDirectory = path.dirname(projectFile) + path.sep;
var projectSpec;
var projectFileTextContent;
try {
projectFileTextContent = fs.readFileSync(projectFile, 'utf8');
}
catch (ex) {
throw new Error(exports.errors.GET_PROJECT_FAILED_TO_OPEN_PROJECT_FILE);
}
try {
projectSpec = tsconfig.parseFileSync(projectFileTextContent, projectFile, { resolvePaths: false });
}
catch (ex) {
throw errorWithDetails(new Error(exports.errors.GET_PROJECT_JSON_PARSE_FAILED), { projectFilePath: fsu.consistentPath(projectFile), error: ex.message });
}
if (!projectSpec.atom) {
projectSpec.atom = {
rewriteTsconfig: false,
};
}
if (projectSpec.filesGlob) {
var prettyJSONProjectSpec = prettyJSON(projectSpec, detectIndent(projectFileTextContent).indent, detectNewline(projectFileTextContent));
if (prettyJSONProjectSpec !== projectFileTextContent && projectSpec.atom.rewriteTsconfig) {
fs.writeFileSync(projectFile, prettyJSONProjectSpec);
}
}
var pkg = null;