+18
-1
@@ -31,4 +31,21 @@ const fs = require('fs'); | ||
| // Create TSC Hook API | ||
| const ignoredConfigOptions = [ 'save', 'ignore', 'path', 'directory' ]; | ||
| const api = { | ||
| tsconfig: createTSConfigAPI(tsconfig, tsconfigPath) | ||
| tsconfig: { | ||
| ...tsconfig, | ||
| save: function() { | ||
| const tsconfigCopy = { ...api.tsconfig }; | ||
| for (const ignoredConfigOption of ignoredConfigOptions) { | ||
| eval(`delete tsconfigCopy.${ignoredConfigOption}`); | ||
| } | ||
| fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfigCopy, null, 2)); | ||
| }, | ||
| ignore: function(configOption) { | ||
| ignoredConfigOptions.add(configOption); | ||
| api.tsconfig.save(); | ||
| }, | ||
| path: tsconfigPath, | ||
| directory: tsconfigDir | ||
| } | ||
| }; | ||
@@ -35,0 +52,0 @@ |
+1
-1
| { | ||
| "name": "tsc-hooks", | ||
| "version": "1.1.1-dev.20210905.5", | ||
| "version": "1.1.1-dev.20210905.6", | ||
| "description": "Add tsc compiler hooks to your TypeScript project", | ||
@@ -5,0 +5,0 @@ "main": "run.js", |
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| module.exports = function(tsconfig, tsconfigPath) { | ||
| const mutableConfig = { ...tsconfig }; | ||
| const setterConfig = {}; | ||
| const ignoredConfigOptions = []; | ||
| let isAutosave = false; | ||
| function updateConfig() { | ||
| const writtenConfig = { ...mutableConfig }; | ||
| for (const ignoredConfigOption of ignoredConfigOptions) { | ||
| eval(`delete writtenConfig.${ignoredConfigOption}`); | ||
| } | ||
| fs.writeFileSync(tsconfigPath, JSON.stringify(writtenConfig, null, 2)); | ||
| } | ||
| function createSettersConfig(mc, sc) { | ||
| for (const key in mc) { | ||
| if (typeof mc[key] === 'object') { | ||
| sc[key] = {}; | ||
| createSettersConfig(mc[key], sc[key]); | ||
| } else { | ||
| Object.defineProperty(sc, key, { | ||
| get() { | ||
| return mc[key]; | ||
| }, | ||
| set(value) { | ||
| mc[key] = value; | ||
| if (isAutosave) updateConfig(); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| createSettersConfig(mutableConfig, setterConfig); | ||
| return { | ||
| ...setterConfig, | ||
| directory: path.dirname(tsconfigPath), | ||
| path: tsconfigPath, | ||
| ignore: function(configOption) { | ||
| ignoredConfigOptions.push(configOption); | ||
| updateConfig(); | ||
| }, | ||
| save: updateConfig, | ||
| autosave: function(isAutosave) { | ||
| isAutosave = isAutosave; | ||
| } | ||
| }; | ||
| } |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
9
-10%107236
-0.75%14
-6.67%135
-17.68%