Skip to content

Commit 3894f27

Browse files
committedJan 6, 2023
💥 Convert package to ESM
Migration Guide: This relases changes the package from a Common JS module to an EcmaScript module, and drops support for older versions of Node. - The minimum version of Node.js supported is now: `14.18.0`, `16.14.0`, and `18.0.0` - The package must now be imported using the native `import` syntax instead of with `require`
1 parent 8178bde commit 3894f27

File tree

8 files changed

+23
-24
lines changed

8 files changed

+23
-24
lines changed
 

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
node_modules/
1+
/node_modules/

‎.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2015 Linus Unnebäck
3+
Copyright (c) 2015, 2023 Linus Unnebäck
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎index.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
declare function applicationConfigPath (name: string): string
2-
export = applicationConfigPath
1+
export default function applicationConfigPath (name: string): string

‎index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var os = require('os')
2-
var path = require('path')
1+
import os from 'node:os'
2+
import path from 'node:path'
33

44
function darwin (name) {
55
return path.join(process.env.HOME, 'Library', 'Application Support', name)
@@ -21,7 +21,7 @@ function win32 (name) {
2121
return path.join(process.env.USERPROFILE, 'Local Settings', 'Application Data', name)
2222
}
2323

24-
function applicationConfigPath (name) {
24+
export default function applicationConfigPath (name) {
2525
if (typeof name !== 'string') {
2626
throw new TypeError('`name` must be string')
2727
}
@@ -36,5 +36,3 @@ function applicationConfigPath (name) {
3636

3737
throw new Error('Platform not supported')
3838
}
39-
40-
module.exports = applicationConfigPath

‎package.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
"version": "0.1.1",
44
"license": "MIT",
55
"author": "Linus Unnebäck <linus@folkdatorn.se>",
6-
"main": "index.js",
7-
"repository": {
8-
"type": "git",
9-
"url": "http://github.com/LinusU/node-application-config-path.git"
6+
"repository": "LinusU/node-application-config-path",
7+
"type": "module",
8+
"exports": "./index.js",
9+
"scripts": {
10+
"test": "standard && mocha"
1011
},
1112
"devDependencies": {
12-
"mocha": "^2.2.5",
13-
"standard": "^5.0.1-0"
13+
"mocha": "^10.2.0",
14+
"standard": "^17.0.0"
1415
},
15-
"scripts": {
16-
"test": "standard && mocha"
16+
"engines": {
17+
"node": "^14.18.0 || ^16.14.0 || >=18.0.0"
1718
}
1819
}

‎README.md ‎readme.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ npm install --save application-config-path
1111
## Usage
1212

1313
```javascript
14-
var applicationConfigPath = require('application-config-path')
14+
import applicationConfigPath from 'application-config-path'
1515

1616
// cfgPath is a string with the path to a directory
1717
// where you can store your config.
18-
var cfgPath = applicationConfigPath('My App')
18+
const cfgPath = applicationConfigPath('My App')
1919
```
2020

2121
## API
2222

2323
### `applicationConfigPath(name)`
2424

25-
Return a string with the path to a directory where you can store your
26-
application specific config.
25+
Return a string with the path to a directory where you can store your application specific config.
2726

2827
## License
2928

‎test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-env mocha */
22

3-
var path = require('path')
4-
var assert = require('assert')
5-
var applicationConfigPath = require('./')
3+
import path from 'node:path'
4+
import assert from 'node:assert'
5+
6+
import applicationConfigPath from './index.js'
67

78
describe('application-config-path', function () {
89
it('should return an absolute path', function () {

0 commit comments

Comments
 (0)
Please sign in to comment.