Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

config-file-ts

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

config-file-ts - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

87

dist/index.js

@@ -5,11 +5,16 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var glob = _interopDefault(require('glob'));
var path = _interopDefault(require('path'));
var glob = require('glob');
var path = require('path');
var ts = require('typescript');
var ts__default = _interopDefault(ts);
var fs = _interopDefault(require('fs'));
var os = _interopDefault(require('os'));
var fs = require('fs');
var os = require('os');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
function tsCompile(fileNames, options) {

@@ -28,3 +33,3 @@ console.log("compiling:", fileNames);

const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
const filePath = path.resolve(diagnostic.file.fileName);
const filePath = path__default['default'].resolve(diagnostic.file.fileName);
console.log(`tsc: (${filePath}:${line + 1}:${character + 1}): ${message}`);

@@ -38,6 +43,6 @@ }

const fsRoot = path.parse(process.cwd()).root;
const fsRoot = path__default['default'].parse(process.cwd()).root;
/** Return true if any files need compiling */
function needsCompile(srcGlobs, outDir) {
const files = srcGlobs.flatMap((src) => glob.sync(src));
const files = srcGlobs.flatMap((src) => glob__default['default'].sync(src));
const srcDestPairs = compilationPairs(files, outDir);

@@ -48,3 +53,3 @@ return anyOutDated(srcDestPairs);

function expectFilesExist(files) {
const missing = files.find((file) => !fs.existsSync(file));
const missing = files.find((file) => !fs__default['default'].existsSync(file));
if (missing) {

@@ -57,8 +62,8 @@ return false;

function jsOutFile(tsFile, outDir) {
const tsAbsolutePath = path.resolve(tsFile);
const tsAbsoluteDir = path.dirname(tsAbsolutePath);
const dirFromRoot = path.relative(fsRoot, tsAbsoluteDir);
const jsDir = path.join(outDir, dirFromRoot);
const outFile = changeSuffix(path.basename(tsFile), ".js");
return path.join(jsDir, outFile);
const tsAbsolutePath = path__default['default'].resolve(tsFile);
const tsAbsoluteDir = path__default['default'].dirname(tsAbsolutePath);
const dirFromRoot = path__default['default'].relative(fsRoot, tsAbsoluteDir);
const jsDir = path__default['default'].join(outDir, dirFromRoot);
const outFile = changeSuffix(path__default['default'].basename(tsFile), ".js");
return path__default['default'].join(jsDir, outFile);
}

@@ -87,8 +92,8 @@ /*

rootDir: fsRoot,
module: ts__default.ModuleKind.CommonJS,
moduleResolution: ts__default.ModuleResolutionKind.NodeJs,
module: ts__default['default'].ModuleKind.CommonJS,
moduleResolution: ts__default['default'].ModuleResolutionKind.NodeJs,
esModuleInterop: true,
skipLibCheck: true,
strict,
target: ts__default.ScriptTarget.ES2019,
target: ts__default['default'].ScriptTarget.ES2019,
noEmitOnError: true,

@@ -120,3 +125,3 @@ });

if (nodeModules) {
const linkToModules = path.join(outDir, "node_modules");
const linkToModules = path__default['default'].join(outDir, "node_modules");
symLinkForce(nodeModules, linkToModules);

@@ -127,9 +132,9 @@ }

function symLinkForce(existing, link) {
if (fs.existsSync(link)) {
if (!fs.lstatSync(link).isSymbolicLink()) {
if (fs__default['default'].existsSync(link)) {
if (!fs__default['default'].lstatSync(link).isSymbolicLink()) {
throw `symLinkForce refusing to unlink non-symlink ${link}`;
}
fs.unlinkSync(link);
fs__default['default'].unlinkSync(link);
}
fs.symlinkSync(existing, link);
fs__default['default'].symlinkSync(existing, link);
}

@@ -140,9 +145,9 @@ /** @return the resolved path to the nearest node_modules file,

function nearestNodeModules(dir) {
const resolvedDir = path.resolve(dir);
const modulesFile = path.join(resolvedDir, "node_modules");
if (fs.existsSync(modulesFile)) {
const resolvedDir = path__default['default'].resolve(dir);
const modulesFile = path__default['default'].join(resolvedDir, "node_modules");
if (fs__default['default'].existsSync(modulesFile)) {
return modulesFile;
}
else {
const { dir: parent, root } = path.parse(resolvedDir);
const { dir: parent, root } = path__default['default'].parse(resolvedDir);
if (parent !== root) {

@@ -166,3 +171,3 @@ return nearestNodeModules(parent);

function compileConfigIfNecessary(tsFile, outDir) {
if (!fs.existsSync(tsFile)) {
if (!fs__default['default'].existsSync(tsFile)) {
console.error("config file:", tsFile, " not found");

@@ -184,7 +189,7 @@ return undefined;

const found = filePairs.find(([srcPath, outPath]) => {
if (!fs.existsSync(outPath)) {
if (!fs__default['default'].existsSync(outPath)) {
return true;
}
const srcTime = fs.statSync(srcPath).mtime;
const outTime = fs.statSync(outPath).mtime;
const srcTime = fs__default['default'].statSync(srcPath).mtime;
const outTime = fs__default['default'].statSync(outPath).mtime;
return srcTime > outTime;

@@ -195,6 +200,6 @@ });

function changeSuffix(filePath, suffix) {
const dir = path.dirname(filePath);
const curSuffix = path.extname(filePath);
const base = path.basename(filePath, curSuffix);
return path.join(dir, base + suffix);
const dir = path__default['default'].dirname(filePath);
const curSuffix = path__default['default'].extname(filePath);
const base = path__default['default'].basename(filePath, curSuffix);
return path__default['default'].join(dir, base + suffix);
}

@@ -215,3 +220,3 @@

}
const end = jsConfig.length - path.extname(jsConfig).length;
const end = jsConfig.length - path__default['default'].extname(jsConfig).length;
const requirePath = jsConfig.slice(0, end);

@@ -223,8 +228,8 @@ const config = require(requirePath);

function defaultOutDir(tsFile, programName = "") {
const tsPath = path.resolve(tsFile);
const tsPath = path__default['default'].resolve(tsFile);
const smushedPath = tsPath
.split(path.sep)
.split(path__default['default'].sep)
.join("-")
.slice(1);
return path.join(os.homedir(), ".cache", programName, smushedPath);
return path__default['default'].join(os__default['default'].homedir(), ".cache", programName, smushedPath);
}

@@ -231,0 +236,0 @@

{
"name": "config-file-ts",
"version": "0.2.1",
"version": "0.2.2",
"main": "dist/index.js",

@@ -21,16 +21,16 @@ "types": "dist/index.d.ts",

"glob": "^7.1.6",
"typescript": "^3.8.3"
"typescript": "^4.0.2"
},
"devDependencies": {
"@types/chai": "^4.2.11",
"@types/glob": "^7.1.1",
"@types/jest": "^25.1.4",
"@types/node": "^13.9.5",
"@types/chai": "^4.2.12",
"@types/glob": "^7.1.3",
"@types/jest": "^26.0.10",
"@types/node": "^14.6.1",
"@types/rimraf": "^3.0.0",
"chai": "^4.2.0",
"jest": "^25.2.4",
"jest": "^26.4.2",
"rimraf": "^3.0.2",
"rollup": "^2.2.0",
"rollup-plugin-typescript2": "^0.27.0",
"ts-jest": "^25.3.0"
"rollup": "^2.26.6",
"rollup-plugin-typescript2": "^0.27.2",
"ts-jest": "^26.3.0"
},

@@ -37,0 +37,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

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