@nx/devkit
Advanced tools
Comparing version 0.0.0-pr-29703-8312c59 to 0.0.0-pr-29705-bc2a0dd
{ | ||
"name": "@nx/devkit", | ||
"version": "0.0.0-pr-29703-8312c59", | ||
"version": "0.0.0-pr-29705-bc2a0dd", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more. Learn more about [extending Nx by leveraging the Nx Devkit](https://nx.dev/extending-nx/intro/getting-started) on our docs.", |
@@ -6,3 +6,3 @@ "use strict"; | ||
function updateTsConfigsToJs(tree, options) { | ||
let updateConfigPath; | ||
let updateConfigPath = null; | ||
const paths = { | ||
@@ -13,11 +13,2 @@ tsConfig: `${options.projectRoot}/tsconfig.json`, | ||
}; | ||
const getProjectType = (tree) => { | ||
if (tree.exists(paths.tsConfigApp)) { | ||
return 'application'; | ||
} | ||
if (tree.exists(paths.tsConfigLib)) { | ||
return 'library'; | ||
} | ||
throw new Error(`project is missing tsconfig.lib.json or tsconfig.app.json`); | ||
}; | ||
(0, devkit_exports_1.updateJson)(tree, paths.tsConfig, (json) => { | ||
@@ -32,19 +23,23 @@ if (json.compilerOptions) { | ||
}); | ||
const projectType = getProjectType(tree); | ||
if (projectType === 'library') { | ||
if (tree.exists(paths.tsConfigLib)) { | ||
updateConfigPath = paths.tsConfigLib; | ||
} | ||
if (projectType === 'application') { | ||
if (tree.exists(paths.tsConfigApp)) { | ||
updateConfigPath = paths.tsConfigApp; | ||
} | ||
(0, devkit_exports_1.updateJson)(tree, updateConfigPath, (json) => { | ||
json.include = uniq([...json.include, 'src/**/*.js']); | ||
json.exclude = uniq([ | ||
...json.exclude, | ||
'src/**/*.spec.js', | ||
'src/**/*.test.js', | ||
]); | ||
return json; | ||
}); | ||
if (updateConfigPath) { | ||
(0, devkit_exports_1.updateJson)(tree, updateConfigPath, (json) => { | ||
json.include = uniq([...json.include, 'src/**/*.js']); | ||
json.exclude = uniq([ | ||
...json.exclude, | ||
'src/**/*.spec.js', | ||
'src/**/*.test.js', | ||
]); | ||
return json; | ||
}); | ||
} | ||
else { | ||
throw new Error(`project is missing tsconfig.lib.json or tsconfig.app.json`); | ||
} | ||
} | ||
const uniq = (value) => [...new Set(value)]; |
208393
5131