Skip to content

Commit bbc7f4c

Browse files
committed
Require Node.js 12 and move to ESM
1 parent b9446c9 commit bbc7f4c

File tree

8 files changed

+20
-25
lines changed

8 files changed

+20
-25
lines changed

Diff for: .github/workflows/main.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 16
1314
- 14
1415
- 12
15-
- 10
16-
- 8
1716
steps:
1817
- uses: actions/checkout@v2
19-
- uses: actions/setup-node@v1
18+
- uses: actions/setup-node@v2
2019
with:
2120
node-version: ${{ matrix.node-version }}
2221
- run: npm install

Diff for: index.d.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The line with the least number of leading whitespace, ignoring empty lines, dete
55
66
@example
77
```
8-
import stripIndent = require('strip-indent');
8+
import stripIndent from 'strip-indent';
99
1010
const string = '\tunicorn\n\t\tcake';
1111
// unicorn
@@ -16,6 +16,4 @@ stripIndent(string);
1616
// cake
1717
```
1818
*/
19-
declare function stripIndent(string: string): string;
20-
21-
export = stripIndent;
19+
export default function stripIndent(string: string): string;

Diff for: index.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict';
2-
const minIndent = require('min-indent');
1+
import minIndent from 'min-indent';
32

4-
module.exports = string => {
3+
export default function stripIndent(string) {
54
const indent = minIndent(string);
65

76
if (indent === 0) {
@@ -11,4 +10,4 @@ module.exports = string => {
1110
const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm');
1211

1312
return string.replace(regex, '');
14-
};
13+
}

Diff for: index.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import {expectType} from 'tsd';
2-
import stripIndent = require('.');
2+
import stripIndent from './index.js';
33

44
expectType<string>(stripIndent('\tunicorn\n\t\tcake'));

Diff for: license

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

3-
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <[email protected]> (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

Diff for: package.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
"description": "Strip leading whitespace from each line in a string",
55
"license": "MIT",
66
"repository": "sindresorhus/strip-indent",
7+
"funding": "https://github.com/sponsors/sindresorhus",
78
"author": {
89
"name": "Sindre Sorhus",
910
"email": "[email protected]",
10-
"url": "sindresorhus.com"
11+
"url": "https://sindresorhus.com"
1112
},
13+
"type": "module",
14+
"exports": "./index.js",
1215
"engines": {
13-
"node": ">=8"
16+
"node": ">=12"
1417
},
1518
"scripts": {
1619
"test": "xo && ava && tsd"
@@ -32,11 +35,11 @@
3235
"string"
3336
],
3437
"dependencies": {
35-
"min-indent": "^1.0.0"
38+
"min-indent": "^1.0.1"
3639
},
3740
"devDependencies": {
38-
"ava": "^1.4.1",
39-
"tsd": "^0.7.2",
40-
"xo": "^0.24.0"
41+
"ava": "^3.15.0",
42+
"tsd": "^0.14.0",
43+
"xo": "^0.39.1"
4144
}
4245
}

Diff for: readme.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ The line with the least number of leading whitespace, ignoring empty lines, dete
66

77
Useful for removing redundant indentation.
88

9-
109
## Install
1110

1211
```
1312
$ npm install strip-indent
1413
```
1514

16-
1715
## Usage
1816

1917
```js
20-
const stripIndent = require('strip-indent');
18+
import stripIndent from 'strip-indent';
2119

2220
const string = '\tunicorn\n\t\tcake';
2321
/*
@@ -32,13 +30,11 @@ unicorn
3230
*/
3331
```
3432

35-
3633
## Related
3734

3835
- [strip-indent-cli](https://github.com/sindresorhus/strip-indent-cli) - CLI for this module
3936
- [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string
4037

41-
4238
---
4339

4440
<div align="center">

Diff for: test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import stripIndent from '.';
2+
import stripIndent from './index.js';
33

44
test('main', t => {
55
t.is(stripIndent('\nunicorn\n'), '\nunicorn\n');

0 commit comments

Comments
 (0)