tsc-esm-fix
Advanced tools
Comparing version 2.6.0 to 2.7.0
{ | ||
"git": { | ||
"commitId": "b17160e74de4c99013d980eea39b927f411319ab", | ||
"commitId": "9b6501e42325d3e2753b46facf7d25157a44fc55", | ||
"repoUrl": "https://github.com/antongolub/tsc-esm-fix", | ||
"repoName": "antongolub/tsc-esm-fix" | ||
}, | ||
"date": "2021-08-18T22:11:08.587Z" | ||
"date": "2021-09-07T16:49:54.557Z" | ||
} |
@@ -0,1 +1,14 @@ | ||
# [2.7.0](https://github.com/antongolub/tsc-esm-fix/compare/v2.6.0...v2.7.0) (2021-09-07) | ||
### Features | ||
* add Node.js ^12.20.0 to supported engines ([b213f1c](https://github.com/antongolub/tsc-esm-fix/commit/b213f1c73d013db88b8a4b84213d3d8cfabc20d9)) | ||
* support custom debug function ([5eed5c0](https://github.com/antongolub/tsc-esm-fix/commit/5eed5c044f5072c307483a4f3b3387bdb498c455)) | ||
### Performance Improvements | ||
* **pkg:** update globby to v12.0.2, update jest to v27.1.0, rm patch-package ([2ed6880](https://github.com/antongolub/tsc-esm-fix/commit/2ed68803d0fd1e85142b2eb7a2ea9d59b23002f7)) | ||
# [2.6.0](https://github.com/antongolub/tsc-esm-fix/compare/v2.5.1...v2.6.0) (2021-08-18) | ||
@@ -2,0 +15,0 @@ |
{ | ||
"name": "tsc-esm-fix", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"private": false, | ||
@@ -14,6 +14,7 @@ "publishConfig": { | ||
"exports": { | ||
"import": "./target/es6/index.mjs" | ||
"import": "./target/es6/index.mjs", | ||
"require": "./target/bundle/tsc-esm-fix.cjs" | ||
}, | ||
"engines": { | ||
"node": ">=14.8" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -25,11 +26,11 @@ "source": "src/main/ts/index.ts", | ||
"scripts": { | ||
"postinstall": "patch-package", | ||
"clean": "rimraf target typings flow-typed buildcache docs coverage buildstamp.json", | ||
"lint": "eslint src/**/*.{ts,js}", | ||
"lint": "eslint src/**/*.{ts,js} scripts", | ||
"lint:fix": "yarn lint --fix", | ||
"format": "prettier --write \"src/**/*.ts\"", | ||
"test": "npm-run-all -p -l lint test:unit test:depcheck test:depaudit", | ||
"test:unit": "jest --config=jest.config.json --runInBand", | ||
"format": "prettier --write \"scripts/**/*.js\" \"src/main/**/*.ts\" \"src/test/(js|ts)**/*.(t|j)s\"", | ||
"test": "npm-run-all -p -l lint test:unit test:it test:depcheck test:depaudit", | ||
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --config=jest.config.json --runInBand", | ||
"test:it": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-modules\" node scripts/js/glob-script-runner.js src/test/**/*.it.js", | ||
"test:deps": "npm-run-all -p -l test:depcheck test:depauditfix", | ||
"test:depcheck": "npm_config_yes=true npx depcheck --ignore-patterns fixtures --ignores tslib,@swissquote/crafty-preset-jest,@types/jest,@types/node,eslint-config-*", | ||
"test:depcheck": "npm_config_yes=true npx depcheck --ignore-patterns fixtures --ignores tslib,@types/jest,@types/node,eslint-config-*", | ||
"test:depaudit": "yarn audit --groups=dependencies --level=moderate; [[ $? -ge 4 ]] && exit 1 || exit 0", | ||
@@ -61,3 +62,3 @@ "test:depauditfix": "npm_config_yes=true npx yarn-audit-fix --audit-level=moderate", | ||
"fs-extra": "^10.0.0", | ||
"globby": "^12.0.1", | ||
"globby": "^12.0.2", | ||
"json5": "^2.2.0", | ||
@@ -69,22 +70,22 @@ "meow": "^10.1.1", | ||
"@qiwi/npm-run-all": "^4.1.7", | ||
"@swissquote/crafty-preset-jest": "^1.15.0", | ||
"@types/jest": "^27.0.1", | ||
"@types/node": "^16.6.1", | ||
"@types/node": "^16.7.13", | ||
"coveralls": "^3.1.1", | ||
"cpy-cli": "^3.1.1", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-config-qiwi": "^1.13.5", | ||
"jest": "^27.0.6", | ||
"jest": "^27.1.0", | ||
"microbundle": "^0.13.3", | ||
"mkdirp": "^1.0.4", | ||
"patch-package": "^6.4.7", | ||
"prettier": "^2.3.2", | ||
"prettier-config-qiwi": "^1.4.2", | ||
"rimraf": "^3.0.2", | ||
"semver": "^7.3.5", | ||
"tempy": "^2.0.0", | ||
"terser": "^5.7.1", | ||
"terser": "^5.7.2", | ||
"ts-jest": "^27.0.5", | ||
"typedoc": "^0.21.5", | ||
"typescript": "4.3" | ||
"typedoc": "^0.21.9", | ||
"typescript": "4.4" | ||
}, | ||
@@ -91,0 +92,0 @@ "repository": { |
@@ -10,2 +10,15 @@ # tsc-esm-fix | ||
- [Problem](#problem) | ||
- [Solutions](#solutions) | ||
- [Features](#features) | ||
- [Getting started](#getting-started) | ||
- [Requirements](#requirements) | ||
- [Install](#install) | ||
- [Usage examples](#usage-examples) | ||
- [CLI](#cli) | ||
- [JS/TS API](#js-ts-api) | ||
- [Alternatives](#alternatives) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
### Problem | ||
@@ -33,6 +46,7 @@ This workaround is aimed to bypass a pair of **tsc** and **ts-jest** issues _right here and right now_. | ||
## Requirements | ||
Node.js >= 14 | ||
## Getting started | ||
### Requirements | ||
Node.js `^12.20.0 || ^14.13.1 || >=16.0.0` | ||
## Install | ||
### Install | ||
```shell | ||
@@ -42,7 +56,7 @@ yarn add -D tsc-esm-fix | ||
## Usage | ||
### Usage examples | ||
```shell | ||
tsc-esm-fix [options] | ||
# to post-process outputs everytime | ||
# to post-process outputs each time | ||
tsc-esm-fix --target='target/es6' | ||
@@ -134,3 +148,2 @@ | ||
## API | ||
### CLI | ||
@@ -146,3 +159,3 @@ ```shell | ||
|`--dirnameVar` | Replace `__dirname` usages with `import.meta` | true | ||
|`--filenameVar` | Replace `__filename` var references `import.meta` | true | ||
|`--filenameVar` | Replace `__filename` var references with `import.meta` statements | true | ||
|`--ext` | Append extension to relative imports/re-exports | `.js` | ||
@@ -154,3 +167,3 @@ |`--unlink` | Remove original files if ext changes | true | ||
### JS/TS | ||
### JS/TS API | ||
```ts | ||
@@ -178,3 +191,4 @@ import { fix, IFixOptions } from 'tsc-esm-fix' | ||
ext: boolean | string | ||
unlink?: boolean | ||
unlink?: boolean, | ||
debug?: boolean | IFunction | ||
} | ||
@@ -187,3 +201,8 @@ ``` | ||
## Contributing | ||
Feel free to open any issues: for bugs, feature requests or questions. | ||
You're always welcome to suggest a PR. Just fork this repo, write some code, add some tests and push your changes. | ||
Any feedback is appreciated. | ||
## License | ||
[MIT](./LICENSE) |
@@ -1,4 +0,4 @@ | ||
import { IFixOptionsNormalized } from './interface'; | ||
import { IFixOptions, IFixOptionsNormalized } from './interface'; | ||
export declare const DEFAULT_FIX_OPTIONS: IFixOptionsNormalized; | ||
export declare const normalizeOptions: (opts?: Partial<IFixOptionsNormalized> | undefined) => IFixOptionsNormalized; | ||
export declare const normalizeOptions: (opts?: IFixOptions | undefined) => IFixOptionsNormalized; | ||
export declare const findTargets: (tsconfig: string | string[], cwd: string) => string[]; | ||
@@ -11,2 +11,2 @@ export declare const resolveDependency: (parent: string, nested: string, files: string[], cwd: string) => string; | ||
export declare const fixContents: (contents: string, filename: string, filenames: string[], { cwd, ext, dirnameVar, filenameVar }: IFixOptionsNormalized) => string; | ||
export declare const fix: (opts?: Partial<IFixOptionsNormalized> | undefined) => Promise<void>; | ||
export declare const fix: (opts?: IFixOptions | undefined) => Promise<void>; |
@@ -0,4 +1,5 @@ | ||
declare type IFunction<A extends any[] = any[], R = any> = (...args: A) => R; | ||
export declare type IFixOptionsNormalized = { | ||
cwd: string; | ||
debug?: boolean; | ||
debug: IFunction; | ||
out?: string; | ||
@@ -17,2 +18,5 @@ src?: string | string[]; | ||
}; | ||
export declare type IFixOptions = Partial<IFixOptionsNormalized>; | ||
export declare type IFixOptions = Partial<Omit<IFixOptionsNormalized, 'debug'>> & { | ||
debug?: boolean | IFunction; | ||
}; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("path"),require("fs"),require("fs-extra"),require("json5"),require("globby")):"function"==typeof define&&define.amd?define(["exports","path","fs","fs-extra","json5","globby"],n):n((e||self).tscEsmFix={},e.path,e.fs,e.fsExtra,e.json5,e.globby)}(this,function(e,n,r,t,o,u){function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=i(t),s=i(o);function l(){return(l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}var a=function(e){return r.readFileSync(e,{encoding:"utf8"})},f=function(e){return s.default.parse(a(e))},d=function(e){return e?Array.isArray(e)?e:[e]:[]},p=r.unlinkSync,m=function(e){return e.replace(/\\/g,"/")},g=function e(r){var t=f(r);if(t.extends){var o=e(n.resolve(n.dirname(r),t.extends));return l({},o,{compilerOptions:l({},o.compilerOptions,t.compilerOptions)})}return t},b={cwd:process.cwd(),tsconfig:"./tsconfig.json",filenameVar:!0,dirnameVar:!0,ext:!0,unlink:!0,debug:!1},v=function(e,r){return d(e).reduce(function(e,t){var o,u,i,c=g(n.resolve(r,t)),s=null==c||null==(o=c.compilerOptions)?void 0:o.outDir,l=null==c||null==(u=c.compilerOptions)||null==(i=u.module)?void 0:i.toLowerCase();return!s||"es2020"!==l&&"esnext"!==l||e.push(s),e},[])},x=function(e,n){return e.map(function(e){return e.replace(/\.[^./\\]+$/,n)})},y=function(e,r,t,o){return e.replace(/(\sfrom |\simport[ (])(["'])([^"']+\/[^"']+)(["'])/g,function(e,u,i,c,s){return""+u+i+function(e,r,t,o){var u=n.dirname(e),i=n.resolve(o,"node_modules"),c=/^\..+\.[^./\\]+$/.test(r)?[r,r.replace(/\.[^./\\]+$/,"")]:[r];return[".js",".cjs",".mjs"].reduce(function(e,n){return c.forEach(function(r){return e.push(""+r+n,r+"/index"+n)}),e},[]).find(function(e){return t.includes(m(n.resolve(i,e)))||t.includes(m(n.resolve(u,e)))})||r}(r,c,t,o)+s})},h=function(e){return e.replace(/__dirname/g,"/file:\\/\\/(.+)\\/[^/]/.exec(import.meta.url)[1]")},j=function(e){return e.replace(/__filename/g,"/file:\\/\\/(.+)/.exec(import.meta.url)[1]")},_=function(e,n,r,t){var o=t.dirnameVar,u=t.filenameVar,i=e;return t.ext&&(i=y(i,n,r,t.cwd)),o&&(i=h(i)),u&&(i=j(i)),i};e.DEFAULT_FIX_OPTIONS=b,e.fix=function(e){try{var r=function(e){return l({},b,e)}(e),t=r.cwd,o=r.target,i=r.src,s=r.tsconfig,g=r.out,y=r.ext,h=r.debug,j=r.unlink,w=n.resolve(t,void 0===g?t:g),F=h?console.log:function(){},O=d(i),P=[].concat(d(o),v(s,t));F("debug:cwd",t),F("debug:outdir",w),F("debug:sources",O),F("debug:targets",P);var E=O.length>0?O.map(function(e){return e+"/**/*.ts"}):P.map(function(e){return e+"/**/*.js"});return Promise.resolve(u.globby(E,{cwd:t,onlyFiles:!0,absolute:!0})).then(function(e){return Promise.resolve(function(e){try{return Promise.resolve(function(e){return u.globby(["node_modules/*/package.json"],{cwd:e,onlyFiles:!0,absolute:!0}).then(function(e){return e.filter(function(e){return f(e).exports}).map(function(e){return n.basename(n.dirname(e))})})}(e)).then(function(n){return u.globby(["node_modules/**/*.(m|c)?js","!node_modules/**/node_modules"].concat(n.map(function(e){return"!node_modules/"+e})),{cwd:e,onlyFiles:!0,absolute:!0})})}catch(e){return Promise.reject(e)}}(t)).then(function(n){F("debug:external-names",n);var o="string"==typeof y?x(e,y):e;F("debug:local-names",o);var u=[].concat(n,o);o.forEach(function(n,o){var s=(i?e[o]:n).replace(m(t),m(w)),l=a(e[o]);!function(e,n){c.default.outputFileSync(e,n,{encoding:"utf8"})}(s,_(l,n,u,r)),!i&&j&&t===w&&s!==e[o]&&p(e[o])})})})}catch(e){return Promise.reject(e)}},e.fixContents=_,e.fixDirnameVar=h,e.fixFilenameExtensions=x,e.fixFilenameVar=j,e.fixModuleReferences=y}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("path"),require("fs"),require("fs-extra"),require("globby"),require("json5")):"function"==typeof define&&define.amd?define(["exports","path","fs","fs-extra","globby","json5"],n):n((e||self).tscEsmFix={},e.path,e.fs,e.fsExtra,e.globby,e.json5)}(this,function(e,n,r,t,o,u){function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=i(t),l=i(u);function s(){return(s=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}var a=function(e){return r.readFileSync(e,{encoding:"utf8"})},f=function(e){return l.default.parse(a(e))},d=function(e){return e?Array.isArray(e)?e:[e]:[]},p=r.unlinkSync,m=function(e){return e.replace(/\\/g,"/")},g=function e(r){var t=f(r);if(t.extends){var o=e(n.resolve(n.dirname(r),t.extends));return s({},o,{compilerOptions:s({},o.compilerOptions,t.compilerOptions)})}return t},b={cwd:process.cwd(),tsconfig:"./tsconfig.json",filenameVar:!0,dirnameVar:!0,ext:!0,unlink:!0,debug:function(){}},v=function(e,r){return d(e).reduce(function(e,t){var o,u,i,c=g(n.resolve(r,t)),l=null==c||null==(o=c.compilerOptions)?void 0:o.outDir,s=null==c||null==(u=c.compilerOptions)||null==(i=u.module)?void 0:i.toLowerCase();return!l||"es2020"!==s&&"esnext"!==s||e.push(l),e},[])},y=function(e,n){return e.map(function(e){return e.replace(/\.[^./\\]+$/,n)})},x=function(e,r,t,o){return e.replace(/(\sfrom |\simport[ (])(["'])([^"']+\/[^"']+)(["'])/g,function(e,u,i,c,l){return""+u+i+function(e,r,t,o){var u=n.dirname(e),i=n.resolve(o,"node_modules"),c=/^\..+\.[^./\\]+$/.test(r)?[r,r.replace(/\.[^./\\]+$/,"")]:[r];return[".js",".cjs",".mjs"].reduce(function(e,n){return c.forEach(function(r){return e.push(""+r+n,r+"/index"+n)}),e},[]).find(function(e){return t.includes(m(n.resolve(i,e)))||t.includes(m(n.resolve(u,e)))})||r}(r,c,t,o)+l})},h=function(e){return e.replace(/__dirname/g,"/file:\\/\\/(.+)\\/[^/]/.exec(import.meta.url)[1]")},j=function(e){return e.replace(/__filename/g,"/file:\\/\\/(.+)/.exec(import.meta.url)[1]")},_=function(e,n,r,t){var o=t.dirnameVar,u=t.filenameVar,i=e;return t.ext&&(i=x(i,n,r,t.cwd)),o&&(i=h(i)),u&&(i=j(i)),i};e.DEFAULT_FIX_OPTIONS=b,e.fix=function(e){try{var r=function(e){return s({},b,e,{debug:"function"==typeof(null==e?void 0:e.debug)?e.debug:!0===(null==e?void 0:e.debug)?console.log:b.debug})}(e),t=r.cwd,u=r.target,i=r.src,l=r.tsconfig,g=r.out,x=r.ext,h=r.debug,j=r.unlink,w=n.resolve(t,void 0===g?t:g),F=d(i),O=[].concat(d(u),v(l,t));h("debug:cwd",t),h("debug:outdir",w),h("debug:sources",F),h("debug:targets",O);var P=F.length>0?F.map(function(e){return e+"/**/*.ts"}):O.map(function(e){return e+"/**/*.js"});return Promise.resolve(o.globby(P,{cwd:t,onlyFiles:!0,absolute:!0})).then(function(e){return Promise.resolve(function(e){try{return Promise.resolve(function(e){return o.globby(["node_modules/*/package.json"],{cwd:e,onlyFiles:!0,absolute:!0}).then(function(e){return e.filter(function(e){return f(e).exports}).map(function(e){return n.basename(n.dirname(e))})})}(e)).then(function(n){return o.globby(["node_modules/**/*.(m|c)?js","!node_modules/**/node_modules"].concat(n.map(function(e){return"!node_modules/"+e})),{cwd:e,onlyFiles:!0,absolute:!0})})}catch(e){return Promise.reject(e)}}(t)).then(function(n){h("debug:external-names",n);var o="string"==typeof x?y(e,x):e;h("debug:local-names",o);var u=[].concat(n,o);o.forEach(function(n,o){var l=(i?e[o]:n).replace(m(t),m(w)),s=a(e[o]);!function(e,n){c.default.outputFileSync(e,n,{encoding:"utf8"})}(l,_(s,n,u,r)),!i&&j&&t===w&&l!==e[o]&&p(e[o])})})})}catch(e){return Promise.reject(e)}},e.fixContents=_,e.fixDirnameVar=h,e.fixFilenameExtensions=y,e.fixFilenameVar=j,e.fixModuleReferences=x}); | ||
//# sourceMappingURL=tsc-esm-fix.umd.js.map |
/// <reference types="node" /> | ||
import { unlinkSync } from 'fs'; | ||
import { globby } from 'globby'; | ||
import { TSConfig } from './interface'; | ||
export { globby, globbySync } from 'globby'; | ||
export { globby }; | ||
export declare const read: (file: string) => string; | ||
@@ -6,0 +7,0 @@ export declare const write: (file: string, contents: string) => void; |
@@ -1,4 +0,4 @@ | ||
import { IFixOptionsNormalized } from './interface'; | ||
import { IFixOptions, IFixOptionsNormalized } from './interface'; | ||
export declare const DEFAULT_FIX_OPTIONS: IFixOptionsNormalized; | ||
export declare const normalizeOptions: (opts?: Partial<IFixOptionsNormalized> | undefined) => IFixOptionsNormalized; | ||
export declare const normalizeOptions: (opts?: IFixOptions | undefined) => IFixOptionsNormalized; | ||
export declare const findTargets: (tsconfig: string | string[], cwd: string) => string[]; | ||
@@ -11,2 +11,2 @@ export declare const resolveDependency: (parent: string, nested: string, files: string[], cwd: string) => string; | ||
export declare const fixContents: (contents: string, filename: string, filenames: string[], { cwd, ext, dirnameVar, filenameVar }: IFixOptionsNormalized) => string; | ||
export declare const fix: (opts?: Partial<IFixOptionsNormalized> | undefined) => Promise<void>; | ||
export declare const fix: (opts?: IFixOptions | undefined) => Promise<void>; |
@@ -0,4 +1,5 @@ | ||
declare type IFunction<A extends any[] = any[], R = any> = (...args: A) => R; | ||
export declare type IFixOptionsNormalized = { | ||
cwd: string; | ||
debug?: boolean; | ||
debug: IFunction; | ||
out?: string; | ||
@@ -17,2 +18,5 @@ src?: string | string[]; | ||
}; | ||
export declare type IFixOptions = Partial<IFixOptionsNormalized>; | ||
export declare type IFixOptions = Partial<Omit<IFixOptionsNormalized, 'debug'>> & { | ||
debug?: boolean | IFunction; | ||
}; | ||
export {}; |
/// <reference types="node" /> | ||
import { unlinkSync } from 'fs'; | ||
import { globby } from 'globby'; | ||
import { TSConfig } from './interface'; | ||
export { globby, globbySync } from 'globby'; | ||
export { globby }; | ||
export declare const read: (file: string) => string; | ||
@@ -6,0 +7,0 @@ export declare const write: (file: string, contents: string) => void; |
@@ -22,3 +22,3 @@ import { basename, dirname, resolve } from 'path' | ||
unlink: true, | ||
debug: false, | ||
debug: () => {}, // eslint-disable-line | ||
} | ||
@@ -28,3 +28,11 @@ | ||
opts?: IFixOptions, | ||
): IFixOptionsNormalized => ({ ...DEFAULT_FIX_OPTIONS, ...opts }) | ||
): IFixOptionsNormalized => ({ | ||
...DEFAULT_FIX_OPTIONS, | ||
...opts, | ||
debug: typeof opts?.debug === 'function' | ||
? opts.debug | ||
: opts?.debug === true | ||
? console.log | ||
: DEFAULT_FIX_OPTIONS.debug, | ||
}) | ||
@@ -155,13 +163,13 @@ export const findTargets = ( | ||
const outDir = resolve(cwd, out) | ||
const dbg = debug ? console.log : () => {} // eslint-disable-line | ||
const sources = asArray<string>(src) | ||
const targets = [...asArray<string>(target), ...findTargets(tsconfig, cwd)] | ||
dbg('debug:cwd', cwd) | ||
dbg('debug:outdir', outDir) | ||
dbg('debug:sources', sources) | ||
dbg('debug:targets', targets) | ||
debug('debug:cwd', cwd) | ||
debug('debug:outdir', outDir) | ||
debug('debug:sources', sources) | ||
debug('debug:targets', targets) | ||
const patterns = sources.length > 0 | ||
? sources.map((src) => `${src}/**/*.ts`) | ||
: targets.map((target) => `${target}/**/*.js`) | ||
const patterns = | ||
sources.length > 0 | ||
? sources.map((src) => `${src}/**/*.ts`) | ||
: targets.map((target) => `${target}/**/*.js`) | ||
@@ -174,11 +182,14 @@ const names = await globby(patterns, { | ||
const externalNames = await getExtModules(cwd) | ||
dbg('debug:external-names', externalNames) | ||
debug('debug:external-names', externalNames) | ||
const _names = | ||
typeof ext === 'string' ? fixFilenameExtensions(names, ext) : names | ||
dbg('debug:local-names', _names) | ||
debug('debug:local-names', _names) | ||
const allNames = [...externalNames, ..._names] | ||
_names.forEach((name, i) => { | ||
const nextName = (!src ? name : names[i]).replace(unixify(cwd), unixify(outDir)) | ||
const nextName = (!src ? name : names[i]).replace( | ||
unixify(cwd), | ||
unixify(outDir), | ||
) | ||
const contents = read(names[i]) | ||
@@ -185,0 +196,0 @@ const _contents = fixContents(contents, name, allNames, _opts) |
@@ -0,4 +1,6 @@ | ||
type IFunction<A extends any[] = any[], R = any> = (...args: A) => R | ||
export type IFixOptionsNormalized = { | ||
cwd: string | ||
debug?: boolean | ||
debug: IFunction | ||
out?: string | ||
@@ -19,2 +21,2 @@ src?: string | string[] | ||
export type IFixOptions = Partial<IFixOptionsNormalized> | ||
export type IFixOptions = Partial<Omit<IFixOptionsNormalized, 'debug'>> & {debug?: boolean | IFunction} |
import { readFileSync, unlinkSync } from 'fs' | ||
import fse from 'fs-extra' | ||
import { globby } from 'globby' | ||
import json5 from 'json5' | ||
@@ -8,3 +9,3 @@ import { dirname, resolve } from 'path' | ||
export { globby, globbySync } from 'globby' | ||
export { globby } | ||
@@ -20,7 +21,3 @@ export const read = (file: string): string => | ||
export const asArray = <T>(value: T[] | T | undefined): T[] => | ||
(value | ||
? Array.isArray(value) | ||
? value | ||
: [value] | ||
: []) | ||
value ? (Array.isArray(value) ? value : [value]) : [] | ||
@@ -27,0 +24,0 @@ export const remove = unlinkSync |
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
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
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
83846
618
201
0
Updatedglobby@^12.0.2