@beemo/config-constants
Advanced tools
Comparing version 1.0.1 to 1.0.2
import type { ProjectReference } from 'typescript'; | ||
export declare function parseJSON<T>(filePath: string): T; | ||
declare type PackageDeps = Record<string, string>; | ||
@@ -3,0 +4,0 @@ interface PackageJSON { |
@@ -26,3 +26,3 @@ 'use strict'; | ||
const IGNORE_LIST = ['node_modules/', 'build/', 'cjs/', 'coverage/', 'dist/', 'esm/', 'lib/', 'mjs/']; // Globs for finding source files, test files, and test utility files | ||
const IGNORE_LIST = ['node_modules/', 'build/', 'cjs/', 'coverage/', 'dist/', 'dts/', 'esm/', 'lib/', 'mjs/', 'umd/']; // Globs for finding source files, test files, and test utility files | ||
@@ -29,0 +29,0 @@ const ALL_FILES_GLOB = '**/{src,tests,__tests__}/**/*.{ts,tsx}'; |
@@ -7,4 +7,21 @@ 'use strict'; | ||
const fs = require('fs'); | ||
const constants = require('./constants.js'); | ||
function _interopDefault(e) { | ||
return e && e.__esModule ? e : { | ||
'default': e | ||
}; | ||
} | ||
const fs__default = /*#__PURE__*/_interopDefault(fs); | ||
function parseJSON(filePath) { | ||
const content = fs__default['default'].readFileSync(filePath, 'utf8').split('\n') // Remove comments from JSON files | ||
.filter(line => !/^\s*(#|\/)/.test(line)).join('\n'); | ||
return JSON.parse(content); | ||
} // PACKAGE.JSON | ||
let packageJson; | ||
@@ -14,8 +31,7 @@ | ||
if (packageJson === undefined) { | ||
// eslint-disable-next-line import/no-dynamic-require | ||
packageJson = require(constants.PACKAGE_JSON_PATH); | ||
packageJson = parseJSON(constants.PACKAGE_JSON_PATH); | ||
} | ||
return packageJson; | ||
} // NODEJS | ||
} // NODE.JS | ||
@@ -55,5 +71,3 @@ | ||
try { | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
const pkg = require('react/package.json'); | ||
const pkg = parseJSON(require.resolve('react/package.json')); | ||
reactVersion = Number.parseFloat(pkg.version); | ||
@@ -87,4 +101,3 @@ return reactVersion; | ||
if (tsconfigJson === undefined) { | ||
// eslint-disable-next-line import/no-dynamic-require | ||
tsconfigJson = require(constants.TSCONFIG_JSON_PATH); | ||
tsconfigJson = parseJSON(constants.TSCONFIG_JSON_PATH); | ||
} | ||
@@ -105,2 +118,3 @@ | ||
exports.getTargetReactVersion = getTargetReactVersion; | ||
exports.parseJSON = parseJSON; | ||
//# sourceMappingURL=helpers.js.map |
@@ -29,2 +29,3 @@ 'use strict'; | ||
exports.getTargetReactVersion = helpers.getTargetReactVersion; | ||
exports.parseJSON = helpers.parseJSON; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@beemo/config-constants", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"release": "1624590167003", | ||
@@ -39,3 +39,3 @@ "description": "Reusable constants for Beemo configurations.", | ||
}, | ||
"gitHead": "2bdc82e8c7016eec416bc9425570a539199bbcb6" | ||
"gitHead": "4be9925f5db4dd229a6e27858369e1abae169f56" | ||
} |
@@ -22,5 +22,7 @@ import path from 'path'; | ||
'dist/', | ||
'dts/', | ||
'esm/', | ||
'lib/', | ||
'mjs/', | ||
'umd/', | ||
]; | ||
@@ -27,0 +29,0 @@ |
@@ -0,4 +1,16 @@ | ||
import fs from 'fs'; | ||
import type { ProjectReference } from 'typescript'; | ||
import { PACKAGE_JSON_PATH, TSCONFIG_JSON_PATH } from './constants'; | ||
export function parseJSON<T>(filePath: string): T { | ||
const content = fs | ||
.readFileSync(filePath, 'utf8') | ||
.split('\n') | ||
// Remove comments from JSON files | ||
.filter((line) => !/^\s*(#|\/)/.test(line)) | ||
.join('\n'); | ||
return JSON.parse(content) as T; | ||
} | ||
// PACKAGE.JSON | ||
@@ -19,4 +31,3 @@ | ||
if (packageJson === undefined) { | ||
// eslint-disable-next-line import/no-dynamic-require | ||
packageJson = require(PACKAGE_JSON_PATH) as PackageJSON; | ||
packageJson = parseJSON(PACKAGE_JSON_PATH); | ||
} | ||
@@ -27,3 +38,3 @@ | ||
// NODEJS | ||
// NODE.JS | ||
@@ -61,4 +72,3 @@ let nodeVersion: number; | ||
try { | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
const pkg = require('react/package.json') as { version: string }; | ||
const pkg = parseJSON<{ version: string }>(require.resolve('react/package.json')); | ||
@@ -99,4 +109,3 @@ reactVersion = Number.parseFloat(pkg.version); | ||
if (tsconfigJson === undefined) { | ||
// eslint-disable-next-line import/no-dynamic-require | ||
tsconfigJson = require(TSCONFIG_JSON_PATH) as TSConfigJSON; | ||
tsconfigJson = parseJSON(TSCONFIG_JSON_PATH); | ||
} | ||
@@ -103,0 +112,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
17469
305
2