Skip to content

Commit

Permalink
WIP Convert to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
mrloop committed Jan 10, 2024
1 parent 4ab0961 commit 92d39a0
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 30 deletions.
19 changes: 0 additions & 19 deletions bin/dev

This file was deleted.

25 changes: 25 additions & 0 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env ts-node

/* eslint-disable node/shebang */

import oclif from '@oclif/core'
import path from 'node:path'
import url from 'node:url'
// eslint-disable-next-line node/no-unpublished-import
import {register} from 'ts-node'

// In dev mode -> use ts-node and dev plugins
process.env.NODE_ENV = 'development'

register({
project: path.join(path.dirname(url.fileURLToPath(import.meta.url)), '..', 'tsconfig.json'),
})

// In dev mode, always show stack traces
oclif.settings.debug = true

// Start the CLI
oclif
.run(process.argv.slice(2), import.meta.url)
.then(oclif.flush)
.catch(oclif.Errors.handle)

Check failure on line 25 in bin/dev.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Prefer top-level await over using a promise chain

Check failure on line 25 in bin/dev.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Prefer top-level await over using a promise chain

Check failure on line 25 in bin/dev.js

View workflow job for this annotation

GitHub Actions / Test (19.x)

Prefer top-level await over using a promise chain
7 changes: 0 additions & 7 deletions bin/run

This file was deleted.

8 changes: 8 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node

import oclif from '@oclif/core'

oclif
.run(process.argv.slice(2), import.meta.url)
.then(oclif.flush)
.catch(oclif.Errors.handle)

Check failure on line 8 in bin/run.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Prefer top-level await over using a promise chain

Check failure on line 8 in bin/run.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Prefer top-level await over using a promise chain

Check failure on line 8 in bin/run.js

View workflow job for this annotation

GitHub Actions / Test (19.x)

Prefer top-level await over using a promise chain
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"netlify-git-branch": "./bin/run"
},
"bugs": "https://github.com/mrloop/netlify-git-branch/issues",
"type": "module",
"dependencies": {
"@oclif/command": "1.8.36",
"@oclif/core": "1.26.2",
Expand Down Expand Up @@ -92,7 +93,7 @@
"posttest": "eslint . --ext .ts --config .eslintrc",
"prepack": "yarn build && oclif manifest && oclif readme",
"release": "release-it",
"test": "DEBUG=netlify-git-branch:* mocha --forbid-only \"test/**/*.test.ts\" --no-timeout",
"test": "DEBUG=netlify-git-branch:* mocha --forbid-only \"test/**/*.test.[jt]s\" --no-timeout",
"version": "oclif readme && git add README.md"
},
"types": "lib/index.d.ts"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/helpers/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('node:path')
import path from 'node:path'
process.env.TS_NODE_PROJECT = path.resolve('test/tsconfig.json')
process.env.NODE_ENV = 'development'

Expand Down
9 changes: 7 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"compilerOptions": {
"composite": true,
"declaration": true,
"importHelpers": true,
"module": "commonjs",
"module": "ES2020",
"moduleResolution": "node",
"outDir": "lib",
"rootDir": "src",
"strict": true,
"target": "es2017"
},
"include": [
"src/**/*"
]
],
"ts-node": {
"esm": true
}
}

0 comments on commit 92d39a0

Please sign in to comment.