config-file-ts
Advanced tools
Comparing version 0.2.6 to 0.2.8-rc1
@@ -7,2 +7,4 @@ /** Return true if any files need compiling */ | ||
export declare function jsOutFile(tsFile: string, outDir: string): string; | ||
export declare let _compileCount: number; | ||
export declare function _withCompileCount(fn: () => void): number; | ||
export declare function compileIfNecessary(sources: string[], outDir: string, strict?: boolean): boolean; | ||
@@ -9,0 +11,0 @@ /** create a symlink, replacing any existing linkfile */ |
@@ -107,2 +107,3 @@ 'use strict'; | ||
esModuleInterop: true, | ||
resolveJsonModule: true, | ||
skipLibCheck: true, | ||
@@ -236,6 +237,7 @@ strict, | ||
* @param outDir location to store the compiled javascript. | ||
* Defaults to $HOME/.cache/config-file-ts/<ts-file-path>/ | ||
* @returns the default exported value from the configuration file or undefined | ||
*/ | ||
function loadTsConfig(tsFile, outDir, strict = true) { | ||
const realOutDir = outDir || defaultOutDir(tsFile, "config-file-ts"); | ||
const realOutDir = outDir || defaultOutDir(tsFile); | ||
const jsConfig = compileConfigIfNecessary(tsFile, realOutDir, strict); | ||
@@ -251,3 +253,3 @@ if (!jsConfig) { | ||
/** @return the directory that will be used to store transpilation output. */ | ||
function defaultOutDir(tsFile, programName = "") { | ||
function defaultOutDir(tsFile, programName = "config-file-ts") { | ||
const tsPath = path.resolve(tsFile); | ||
@@ -258,3 +260,3 @@ let smushedPath = tsPath | ||
.slice(1); | ||
if (os.platform.name === "win32") { | ||
if (os.platform() === "win32") { | ||
smushedPath = smushedPath.replace(/^:/, ""); | ||
@@ -261,0 +263,0 @@ } |
@@ -6,6 +6,7 @@ /** Load a typescript configuration file. | ||
* @param outDir location to store the compiled javascript. | ||
* Defaults to $HOME/.cache/config-file-ts/<ts-file-path>/ | ||
* @returns the default exported value from the configuration file or undefined | ||
*/ | ||
export declare function loadTsConfig<T>(tsFile: string, outDir?: string, strict?: boolean): T | undefined; | ||
export declare function loadTsConfig<T>(tsFile: string, outDir?: string | undefined, strict?: boolean): T | undefined; | ||
/** @return the directory that will be used to store transpilation output. */ | ||
export declare function defaultOutDir(tsFile: string, programName?: string): string; |
{ | ||
"name": "config-file-ts", | ||
"version": "0.2.6", | ||
"version": "0.2.8-rc1", | ||
"main": "dist/index.js", | ||
@@ -20,16 +20,12 @@ "types": "dist/index.d.ts", | ||
"dependencies": { | ||
"glob": "^10.3.10", | ||
"typescript": "^5.3.3" | ||
"glob": "^10.3.12", | ||
"typescript": "^5.4.3" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.3.11", | ||
"@types/glob": "^8.1.0", | ||
"@types/jest": "^29.5.11", | ||
"@types/node": "^20.10.5", | ||
"chai": "^4.3.10", | ||
"jest": "^29.7.0", | ||
"@types/node": "^20.11.30", | ||
"rimraf": "^5.0.5", | ||
"rollup": "^4.9.1", | ||
"rollup": "^4.13.2", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"ts-jest": "^29.1.1" | ||
"vitest": "^1.4.0" | ||
}, | ||
@@ -47,5 +43,4 @@ "repository": { | ||
"scripts": { | ||
"test": "jest", | ||
"prepublish": "rimraf dist && rollup -c" | ||
"test": "vitest" | ||
} | ||
} |
@@ -35,2 +35,11 @@ import { glob } from "glob"; | ||
// for tests | ||
export let _compileCount = 0; | ||
export function _withCompileCount(fn:() => void):number { | ||
_compileCount = 0; | ||
fn(); | ||
return _compileCount; | ||
} | ||
/* | ||
@@ -54,2 +63,3 @@ We set rootDir to fsRoot for tsc compilation. | ||
export function compileIfNecessary( | ||
@@ -63,2 +73,3 @@ sources: string[], | ||
if (needsCompile(allSources, outDir)) { | ||
_compileCount++; | ||
const { compiled, localSources } = tsCompile(sources, { | ||
@@ -70,2 +81,3 @@ outDir, | ||
esModuleInterop: true, | ||
resolveJsonModule: true, | ||
skipLibCheck: true, | ||
@@ -72,0 +84,0 @@ strict, |
@@ -9,3 +9,4 @@ import { compileConfigIfNecessary } from "./compileUtil"; | ||
* @param T type of default export value in the configuration file | ||
* @param outDir location to store the compiled javascript. | ||
* @param outDir location to store the compiled javascript. | ||
* Defaults to $HOME/.cache/config-file-ts/<ts-file-path>/ | ||
* @returns the default exported value from the configuration file or undefined | ||
@@ -15,6 +16,6 @@ */ | ||
tsFile: string, | ||
outDir?: string, | ||
outDir?: string | undefined, | ||
strict = true | ||
): T | undefined { | ||
const realOutDir = outDir || defaultOutDir(tsFile, "config-file-ts"); | ||
const realOutDir = outDir || defaultOutDir(tsFile); | ||
const jsConfig = compileConfigIfNecessary(tsFile, realOutDir, strict); | ||
@@ -34,3 +35,3 @@ if (!jsConfig) { | ||
tsFile: string, | ||
programName: string = "" | ||
programName: string = "config-file-ts" | ||
): string { | ||
@@ -42,3 +43,3 @@ const tsPath = path.resolve(tsFile); | ||
.slice(1); | ||
if (platform.name === "win32") { | ||
if (platform() === "win32") { | ||
smushedPath = smushedPath.replace(/^:/, ""); | ||
@@ -45,0 +46,0 @@ } |
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
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
42534
6
598
Updatedglob@^10.3.12
Updatedtypescript@^5.4.3