Skip to content

Commit

Permalink
Require Node.js 12 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 3, 2021
1 parent b066bdf commit 99f0f99
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 10
- 8
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
6 changes: 2 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Check if a path is in the [current working directory](https://en.wikipedia.org/w
@example
```
import isPathInCwd = require('is-path-in-cwd');
import isPathInCwd from 'is-path-in-cwd';
isPathInCwd('unicorn');
//=> true
Expand All @@ -15,6 +15,4 @@ isPathInCwd('.');
//=> false
```
*/
declare function isPathInCwd(path: string): boolean;

export = isPathInCwd;
export default function isPathInCwd(path: string): boolean;
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
const isPathInside = require('is-path-inside');
import isPathInside from 'is-path-inside';

module.exports = path => isPathInside(path, process.cwd());
export default function isPathInCwd(path) {
return isPathInside(path, process.cwd());
}
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 isPathInCwd = require('.');
import isPathInCwd from './index.js';

expectType<boolean>(isPathInCwd('unicorn'));
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"description": "Check if a path is in the current working directory",
"license": "MIT",
"repository": "sindresorhus/is-path-in-cwd",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -31,11 +34,11 @@
"inside"
],
"dependencies": {
"is-path-inside": "^3.0.1"
"is-path-inside": "^4.0.0"
},
"devDependencies": {
"ava": "^2.1.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.39.1"
}
}
5 changes: 1 addition & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

> Check if a path is in the [current working directory](https://en.wikipedia.org/wiki/Working_directory)

## Install

```
$ npm install is-path-in-cwd
```


## Usage

```js
const isPathInCwd = require('is-path-in-cwd');
import isPathInCwd from 'is-path-in-cwd';

isPathInCwd('unicorn');
//=> true
Expand All @@ -25,7 +23,6 @@ isPathInCwd('.');
//=> false
```


---

<div align="center">
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import isPathInCwd from '.';
import isPathInCwd from './index.js';

test('main', t => {
t.true(isPathInCwd('foo'));
Expand Down

0 comments on commit 99f0f99

Please sign in to comment.