Skip to content

Commit

Permalink
refactor: migrate to ESM
Browse files Browse the repository at this point in the history
closes #3, resolves #4, closes #5

BREAKING CHANGE: this package now uses native ESM modules, which means this plugin will only work with inquirer v9 and above.
  • Loading branch information
haversnail committed Oct 12, 2022
1 parent 334956c commit 4b0a7af
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
2 changes: 1 addition & 1 deletion .releaserc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
plugins: [
// prettier-ignore
["@semantic-release/commit-analyzer", {
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ A comprehensive date prompt plugin for Inquirer.js.
npm install inquirer-date-prompt
```

> :warning: Note that the latest version of this package uses native ESM modules, which means this plugin will only work with inquirer `v9` and above. If you cannot use ESM modules yet for whatever reason, you can rely on `v2.x` until you're ready to upgrade your environment:
>
> ```sh
> npm install --save inquirer-date-prompt@^2.0.0
> ```
## Usage

```js
const inquirer = require("inquirer");
import inquirer from "inquirer";
import DatePrompt from "inquirer-date-prompt";

inquirer.registerPrompt("date", require("inquirer-date-prompt"));
inquirer.registerPrompt("date", DatePrompt);

inquirer.prompt({
type: "date",
Expand Down Expand Up @@ -106,4 +113,4 @@ async function getTimestamp(date) {

## Caveats

1. Be aware that even though this plugin works with Node ≥ v10, specifying a locale other than `'en-US'` while running on any version less than 13.0.0 will fail silently. See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#browser_compatibility) for more details.
1. Be aware that even though this plugin works with Node ≥ v12, specifying a locale other than `'en-US'` while running on any version less than 13.0.0 will fail silently. See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#browser_compatibility) for more details.
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const chalk = require("chalk");
const cliCursor = require("cli-cursor");
const Prompt = require("inquirer/lib/prompts/base");
const observe = require("inquirer/lib/utils/events");
const { map, takeUntil } = require("rxjs/operators");
import chalk from "chalk";
import cliCursor from "cli-cursor";
import Prompt from "inquirer/lib/prompts/base.js";
import observe from "inquirer/lib/utils/events.js";
import { map, takeUntil } from "rxjs/operators";

/**
* A lookup object that maps each date part type to the corresponding
Expand Down Expand Up @@ -262,4 +262,4 @@ class DatePrompt extends Prompt {
}
}

module.exports = DatePrompt;
export default DatePrompt;
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "inquirer-date-prompt",
"version": "2.0.1",
"description": "A date prompt plugin for Inquirer.js.",
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"keywords": [
Expand All @@ -20,11 +21,11 @@
},
"homepage": "https://github.com/haversnail/inquirer-date-prompt",
"engines": {
"node": ">=10"
"node": ">=12"
},
"license": "MIT",
"peerDependencies": {
"inquirer": ">= 7.x"
"inquirer": ">= 9.x"
},
"devDependencies": {
"@semantic-release/git": "^9.0.0",
Expand Down

0 comments on commit 4b0a7af

Please sign in to comment.