Skip to content

Commit ea662af

Browse files
committed
Require Node.js 18 and move to ESM
1 parent 1a00616 commit ea662af

File tree

6 files changed

+29
-35
lines changed

6 files changed

+29
-35
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 14
14-
- 12
15-
- 10
16-
- 8
17-
- 6
13+
- 20
14+
- 18
1815
steps:
19-
- uses: actions/checkout@v2
20-
- uses: actions/setup-node@v1
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
2118
with:
2219
node-version: ${{ matrix.node-version }}
2320
- run: npm install

index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
'use strict';
2-
const fs = require('fs');
3-
const path = require('path');
1+
import fs from 'fs';
2+
import path from 'path';
3+
import {fileURLToPath} from 'node:url';
44

5-
module.exports = () => fs.readFileSync(path.join(__dirname, 'cows.txt'), 'utf8')
6-
.replace(/\n$/, '').split('\n\n\n');
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
export default function cows() {
8+
return fs.readFileSync(path.join(__dirname, 'cows.txt'), 'utf8')
9+
.replace(/\n$/, '').split('\n\n\n');
10+
}

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

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

55
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:
66

package.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,33 @@
44
"description": "ASCII cows 🐮",
55
"license": "MIT",
66
"repository": "sindresorhus/cows",
7+
"funding": "https://github.com/sponsors/sindresorhus",
78
"author": {
89
"name": "Sindre Sorhus",
910
"email": "sindresorhus@gmail.com",
10-
"url": "sindresorhus.com"
11+
"url": "https://sindresorhus.com"
1112
},
13+
"type": "module",
14+
"exports": "./index.js",
15+
"sideEffects": false,
1216
"engines": {
13-
"node": ">=6"
17+
"node": ">=18"
1418
},
1519
"scripts": {
16-
"test": "xo && ava"
20+
"//test": "xo && ava",
21+
"test": "ava"
1722
},
1823
"files": [
1924
"index.js",
20-
"cows.txt",
21-
"cowbell"
25+
"cows.txt"
2226
],
2327
"keywords": [
2428
"cows",
2529
"cow",
2630
"ascii"
2731
],
2832
"devDependencies": {
29-
"ava": "^0.25.0",
30-
"xo": "^0.23.0"
33+
"ava": "^6.1.2",
34+
"xo": "^0.58.0"
3135
}
3236
}

readme.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ The list is just a [text file](cows.txt) and can be used wherever.
66

77
![](https://cloud.githubusercontent.com/assets/170270/13090998/a9cdd6b0-d52b-11e5-83ec-614143c9a3bb.png)
88

9-
109
## Examples
1110

1211
```
@@ -87,36 +86,26 @@ _______| /\_| /\_| /\_| /\_| |________
8786
Cow-mobile
8887
```
8988

90-
9189
## Install
9290

93-
```
94-
$ npm install cows
91+
```sh
92+
npm install cows
9593
```
9694

97-
9895
## Usage
9996

10097
```js
101-
const cows = require('cows');
98+
import cows from 'cows';
10299

103100
cows();
104101
```
105102

106-
107103
## API
108104

109105
### cows()
110106

111107
Returns an array of cows.
112108

113-
114109
## Related
115110

116111
- [vaca](https://github.com/sindresorhus/vaca) - Get a random ASCII cow 🐮
117-
- [cows-docker](https://github.com/alexellis/cows-docker) - ASCII cows on Docker
118-
119-
120-
## License
121-
122-
MIT © [Sindre Sorhus](https://sindresorhus.com)

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import cows from '.';
2+
import cows from './index.js';
33

44
test('main', t => {
55
const cowList = cows();

0 commit comments

Comments
 (0)