Skip to content

Commit 2218f15

Browse files
committed
feat: use 'module.parent.filename' when possible, do not fail in esm
1 parent 599f73c commit 2218f15

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.4.1 (03/13/2022)
2+
3+
- use `module.parent.filename` when possible, do not fail in esm
4+
15
# 0.4.0 (3/31/2019)
26

37
- adds list option that will allow you to define a list type

Diff for: index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const { dedent, flatten } = require('./util')
2020
function Woof (helpMessage, options = {}) {
2121
delete require.cache[__filename]
2222

23-
const parentDir = path.dirname(module.parent.filename)
24-
2523
const program = {}
2624
const { version, defaultCommand, args = process.argv.slice(2), flags = {}, commands = {} } = options
2725

@@ -69,6 +67,8 @@ function Woof (helpMessage, options = {}) {
6967
} else {
7068
// try to get the version from the current applications package.json
7169
try {
70+
const parentDir = path.dirname(module.parent.filename);
71+
7272
process.stdout.write(`v${require(`${parentDir}/package.json`).version}\n`)
7373
} catch (ex) {
7474
process.stdout.write('v?\n')

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "woof",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "🐶 command line applications made as easy as fetch",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)