Skip to content

Commit

Permalink
6.0.0: #96: try to fix typescript moduleResolution Node16
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Sep 17, 2024
1 parent ee70c66 commit 7047400
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 14 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/no-track
/test/ts/*.js
/legacy.js
/index.mjs
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# build target
/index.mjs

# test
test/ts/*.js
/.tap
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_script:
- node --version
- npm --version
# run tests
- npm run test:no-coverage
- npm run test:only

# Don't actually build.
build: false
4 changes: 1 addition & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export interface Options {
*/
declare function ignore(options?: Options): Ignore

declare namespace ignore {
export function isPathValid (pathname: string): boolean
}
export function isPathValid (pathname: string): boolean

export default ignore
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,6 @@ const isPathValid = path =>

factory.isPathValid = isPathValid

// Fixes typescript
factory.default = factory

module.exports = factory

// Windows
// --------------------------------------------------------------
Expand Down Expand Up @@ -634,3 +630,10 @@ if (
REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)
|| isNotRelative(path)
}

// COMMONJS_EXPORTS ////////////////////////////////////////////////////////////

// Fixes typescript
factory.default = factory

module.exports = factory
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{
"name": "ignore",
"version": "5.3.2",
"version": "6.0.0",
"description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.",
"main": "index.js",
"module": "index.mjs",
"types": "index.d.ts",
"files": [
"legacy.js",
"index.js",
"index.mjs",
"index.d.ts",
"LICENSE-MIT"
],
"scripts": {
"prepublishOnly": "npm run build",
"build": "babel -o legacy.js index.js",
"build": "babel -o legacy.js index.js && node ./scripts/build.js",
"test:lint": "eslint .",
"test:tsc": "tsc ./test/ts/simple.ts --lib ES6",
"test:tsc:16": "tsc ./test/ts/simple.ts --lib ES6 --moduleResolution Node16 --module Node16",
"test:ts": "node ./test/ts/simple.js",
"tap": "tap --reporter classic",
"test:git": "npm run tap test/git-check-ignore.js",
Expand All @@ -21,7 +26,7 @@
"test:others": "npm run tap test/others.js",
"test:cases": "npm run tap test/*.js -- --coverage",
"test:no-coverage": "npm run tap test/*.js -- --no-check-coverage",
"test:only": "npm run test:lint && npm run test:tsc && npm run test:ts && npm run test:cases",
"test:only": "npm run test:lint && npm run build && npm run test:tsc && npm run test:tsc:16 && npm run test:ts && npm run test:cases",
"test": "npm run test:only",
"test:win32": "IGNORE_TEST_WIN32=1 npm run test",
"report": "tap --coverage-report=html",
Expand Down Expand Up @@ -66,7 +71,7 @@
"spawn-sync": "^2.0.0",
"tap": "^16.3.9",
"tmp": "0.2.3",
"typescript": "^5.1.6"
"typescript": "^5.6.2"
},
"engines": {
"node": ">= 4"
Expand Down
18 changes: 18 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const fs = require('fs')
const {join} = require('path')

const content = fs
.readFileSync(join(__dirname, '..', 'index.js'), 'utf-8')
.toString()
.replace(
/\/\/\sCOMMONJS_EXPORTS[\s\S]+$/,
`
export {
isPathValid
}
export default factory
`
)

fs.writeFileSync(join(__dirname, '..', 'index.mjs'), content)
7 changes: 5 additions & 2 deletions test/ts/simple.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import ignore from '../../'
import {Ignore} from '../../'
import {
Ignore,
isPathValid
} from '../../'

const equal = (actual, expect, message) => {
if (actual !== expect) {
Expand Down Expand Up @@ -40,7 +43,7 @@ const ig5 = ignore({
ignorecase: false
})

const isValid: boolean = ignore.isPathValid('./foo')
const isValid: boolean = isPathValid('./foo')
equal(isValid, false, './foo is not valid')

const {
Expand Down

0 comments on commit 7047400

Please sign in to comment.