Skip to content

Commit

Permalink
Require Node.js 18 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Dec 12, 2023
1 parent cbdd491 commit 077250c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ on:
- pull_request
jobs:
test:
name: Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
name: Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 20
- 18
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export default function stripFinalNewline(input) {
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
const LF = typeof input === 'string' ? '\n' : '\n'.codePointAt();
const CR = typeof input === 'string' ? '\r' : '\r'.codePointAt();

if (input[input.length - 1] === LF) {
if (input.at(-1) === LF) {
input = input.slice(0, -1);
}

if (input[input.length - 1] === CR) {
if (input.at(-1) === CR) {
input = input.slice(0, -1);
}

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
"node": ">=18"
},
"scripts": {
"test": "xo && ava"
Expand All @@ -37,7 +37,7 @@
"buffer"
],
"devDependencies": {
"ava": "^3.15.0",
"xo": "^0.39.1"
"ava": "^6.0.1",
"xo": "^0.56.0"
}
}
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {Buffer} from 'node:buffer';
import test from 'ava';
import stripFinalNewline from './index.js';

Expand Down

0 comments on commit 077250c

Please sign in to comment.