New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tsconfig-generator

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsconfig-generator - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

21

index.js
#!/usr/bin/env node
const _ = require('lodash');
const fs = require('fs');

@@ -12,3 +13,3 @@ const path = require('path');

program
.version('0.0.4')
.version('0.0.5')
.option('-i, --input [inputFile]', 'Specifies the path of the input JSON file')

@@ -23,4 +24,8 @@ .option('-o, --output [outputFile]', 'Specifies the path of the output JSON file')

let config = JSON.parse(fs.readFileSync(inputFilePath, 'utf8'));
replaceConfigKeyIfExists(config, 'compilerOptions.baseUrl', path.dirname(outputFilePath));
replaceConfigKeyIfExists(config, 'extends', path.dirname(outputFilePath));
const absoluteBaseUrlPath = replaceAllMatches(environmentVariableRegex, config.compilerOptions.baseUrl);
config.compilerOptions.baseUrl = getRelativePathTo(path.dirname(outputFilePath), absoluteBaseUrlPath);
walkTheObjectAndReplaceEnvironmentVariables(config, absoluteBaseUrlPath);

@@ -77,2 +82,14 @@ fs.writeFileSync(outputFilePath ? outputFilePath : DEFAULT_TS_CONFIG_FILE_PATH, JSON.stringify(config, null,

});
}
function replaceConfigKeyIfExists(config, keyPathToReplace, targetPath)
{
if(!_.has(config, keyPathToReplace))
{
return;
}
const valueToReplace = _.get(config, keyPathToReplace);
const pathFromEnvVar = replaceAllMatches(environmentVariableRegex, valueToReplace);
_.set(config, keyPathToReplace, path.isAbsolute(pathFromEnvVar) ? getRelativePathTo(targetPath, pathFromEnvVar) : pathFromEnvVar);
}

5

package.json

@@ -8,3 +8,4 @@ {

"dependencies": {
"commander": "^2.15.1"
"commander": "^2.15.1",
"lodash": "4.17.10"
},

@@ -34,3 +35,3 @@ "description": "Creates a tsconfig.json by using the paths defined with environment variables",

},
"version": "0.0.4"
"version": "0.0.5"
}
{
"extends": "../../test/git/root/tsconfig.json",
"compilerOptions": {
"alwaysStrict": true,
"baseUrl": "../../../test/git",
"baseUrl": "../../test/git/root",
"declaration": true,

@@ -33,2 +34,2 @@ "experimentalDecorators": true,

}
}
}
{
"extends": "${TEST_GIT_ROOT}/tsconfig.json",
"compilerOptions": {

@@ -3,0 +4,0 @@ "alwaysStrict": true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc