From 99f0f99ce92522f241af7329e0105b6aa9f6205c Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 3 May 2021 20:02:11 +0700 Subject: [PATCH] Require Node.js 12 and move to ESM --- .github/workflows/main.yml | 5 ++--- index.d.ts | 6 ++---- index.js | 7 ++++--- index.test-d.ts | 2 +- license | 2 +- package.json | 15 +++++++++------ readme.md | 5 +---- test.js | 2 +- 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18531b3..3b8aa86 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/index.d.ts b/index.d.ts index 6e2fb02..896881d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 @@ -15,6 +15,4 @@ isPathInCwd('.'); //=> false ``` */ -declare function isPathInCwd(path: string): boolean; - -export = isPathInCwd; +export default function isPathInCwd(path: string): boolean; diff --git a/index.js b/index.js index 6a2646c..8e555aa 100644 --- a/index.js +++ b/index.js @@ -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()); +} diff --git a/index.test-d.ts b/index.test-d.ts index 769fde4..eda1193 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,4 +1,4 @@ import {expectType} from 'tsd'; -import isPathInCwd = require('.'); +import isPathInCwd from './index.js'; expectType(isPathInCwd('unicorn')); diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (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: diff --git a/package.json b/package.json index c6082ec..1358b8d 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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" } } diff --git a/readme.md b/readme.md index 93e56a3..162a7a0 100644 --- a/readme.md +++ b/readme.md @@ -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 @@ -25,7 +23,6 @@ isPathInCwd('.'); //=> false ``` - ---
diff --git a/test.js b/test.js index 3cd1123..bda323f 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,5 @@ import test from 'ava'; -import isPathInCwd from '.'; +import isPathInCwd from './index.js'; test('main', t => { t.true(isPathInCwd('foo'));