Skip to content

Commit

Permalink
Require Node.js 12.20 and move to ESM
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
sindresorhus committed Aug 25, 2021
1 parent c757835 commit 8968c9b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 29 deletions.
3 changes: 0 additions & 3 deletions .github/funding.yml

This file was deleted.

6 changes: 2 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ jobs:
fail-fast: false
matrix:
node-version:
- 14
- 12
- 10
- 16
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
8 changes: 2 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/**
Fix the `$PATH` on macOS when run from a GUI app.
Useful for Electron apps as GUI apps on macOS doesn't inherit the `$PATH` defined in your dotfiles *(.bashrc/.bash_profile/.zshrc/etc)*.
```
import fixPath = require('fix-path');
import fixPath from 'fix-path';
console.log(process.env.PATH);
//=> '/usr/bin'
Expand All @@ -15,6 +13,4 @@ console.log(process.env.PATH);
//=> '/usr/local/bin:/usr/bin'
```
*/
declare function fixPath(): void;

export = fixPath;
export default function fixPath(): void;
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';
const shellPath = require('shell-path');
import process from 'node:process';
import {shellPathSync} from 'shell-path';

module.exports = () => {
export default function fixPath() {
if (process.platform !== 'darwin') {
return;
}

process.env.PATH = shellPath.sync() || [
process.env.PATH = shellPathSync() || [
'./node_modules/.bin',
'/.nodebrew/current/bin',
'/usr/local/bin',
process.env.PATH
process.env.PATH,
].join(':');
};
}
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expectType} from 'tsd';
import fixPath = require('.');
import fixPath from './index.js';

expectType<void>(fixPath());
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"email": "[email protected]",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=10"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -24,7 +26,6 @@
"fix",
"path",
"macos",
"osx",
"env",
"environment",
"variable",
Expand All @@ -34,11 +35,11 @@
"electron"
],
"dependencies": {
"shell-path": "^2.1.0"
"shell-path": "^3.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.11.0",
"xo": "^0.26.1"
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.44.0"
}
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> Fix the `$PATH` on macOS when run from a GUI app
Useful for Electron apps as GUI apps on macOS doesn't inherit the `$PATH` defined in your dotfiles *(.bashrc/.bash_profile/.zshrc/etc)*.
Useful for Electron apps as GUI apps on macOS do not inherit the `$PATH` defined in your dotfiles *(.bashrc/.bash_profile/.zshrc/etc)*.

## Install

Expand All @@ -13,7 +13,7 @@ $ npm install fix-path
## Usage

```js
const fixPath = require('fix-path');
import fixPath from 'fix-path';

console.log(process.env.PATH);
//=> '/usr/bin'
Expand Down
3 changes: 2 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import process from 'node:process';
import test from 'ava';
import fixPath from '.';
import fixPath from './index.js';

test('main', t => {
fixPath();
Expand Down

0 comments on commit 8968c9b

Please sign in to comment.