Skip to content

Commit cba3950

Browse files
committed
Require Node.js 18 and move to ESM
1 parent 8abb09d commit cba3950

File tree

8 files changed

+81
-64
lines changed

8 files changed

+81
-64
lines changed

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
* text=auto
2-
*.js text eol=lf
1+
* text=auto eol=lf

.github/workflows/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Node.js ${{ matrix.node-version }}
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
node-version:
13+
- 20
14+
- 18
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
- run: npm install
21+
- run: npm test

.travis.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

index.js

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
1-
'use strict';
2-
const through = require('through2');
3-
const stripCssComments = require('strip-css-comments');
4-
const PluginError = require('plugin-error');
5-
6-
module.exports = options => {
7-
return through.obj(function (file, enc, cb) {
8-
if (file.isNull()) {
9-
cb(null, file);
10-
}
11-
12-
if (file.isStream()) {
13-
cb(new PluginError('gulp-strip-css-comments', 'Streaming not supported'));
14-
return;
15-
}
16-
17-
try {
18-
file.contents = Buffer.from(stripCssComments(file.contents.toString(), options));
19-
this.push(file);
20-
} catch (err) {
21-
this.emit('error', new PluginError('gulp-strip-css-comments', err, {fileName: file.path}));
22-
}
23-
24-
cb();
1+
import {Buffer} from 'node:buffer';
2+
import stripCssComments from 'strip-css-comments';
3+
import {gulpPlugin} from 'gulp-plugin-extras';
4+
5+
export default function gulpStripCssComments(options) {
6+
return gulpPlugin('gulp-strip-css-comments', file => {
7+
file.contents = Buffer.from(stripCssComments(file.contents.toString(), options));
8+
return file;
259
});
26-
};
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 <[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

package.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
"description": "Strip comments from CSS",
55
"license": "MIT",
66
"repository": "sindresorhus/gulp-strip-css-comments",
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": ">=4"
16+
"node": ">=18"
1417
},
1518
"scripts": {
1619
"test": "xo && ava"
@@ -33,13 +36,21 @@
3336
"string"
3437
],
3538
"dependencies": {
36-
"plugin-error": "^0.1.2",
37-
"strip-css-comments": "^3.0.0",
38-
"through2": "^2.0.0"
39+
"gulp-plugin-extras": "^0.2.2",
40+
"strip-css-comments": "^5.0.0"
3941
},
4042
"devDependencies": {
41-
"ava": "*",
42-
"vinyl": "^2.1.0",
43-
"xo": "^0.18.2"
43+
"ava": "^5.3.1",
44+
"p-event": "^6.0.0",
45+
"vinyl": "^3.0.0",
46+
"xo": "^0.56.0"
47+
},
48+
"peerDependencies": {
49+
"gulp": ">=4"
50+
},
51+
"peerDependenciesMeta": {
52+
"gulp": {
53+
"optional": true
54+
}
4455
}
4556
}

readme.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
1-
# gulp-strip-css-comments [![Build Status](https://travis-ci.org/sindresorhus/gulp-strip-css-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/gulp-strip-css-comments)
1+
# gulp-strip-css-comments
22

33
> Strip comments from CSS using [`strip-css-comments`](https://github.com/sindresorhus/strip-css-comments)
44
5-
65
## Install
76

8-
```
9-
$ npm install --save-dev gulp-strip-css-comments
7+
```sh
8+
npm install --save-dev gulp-strip-css-comments
109
```
1110

12-
1311
## Usage
1412

1513
```js
16-
const gulp = require('gulp');
17-
const stripCssComments = require('gulp-strip-css-comments');
14+
import gulp from 'gulp';
15+
import stripCssComments from 'gulp-strip-css-comments';
1816

19-
gulp.task('default', () =>
17+
export default () => (
2018
gulp.src('src/app.css')
2119
.pipe(stripCssComments())
2220
.pipe(gulp.dest('dist'))
2321
);
2422
```
2523

26-
27-
## stripCssComments([options])
24+
## stripCssComments(options?)
2825

2926
### options
3027

31-
See the `strip-css-comments` [options](https://github.com/sindresorhus/strip-css-comments#options).
32-
28+
Type: `object`
3329

34-
## License
35-
36-
MIT © [Sindre Sorhus](https://sindresorhus.com)
30+
See the `strip-css-comments` [options](https://github.com/sindresorhus/strip-css-comments#options).

test.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1+
import {Buffer} from 'node:buffer';
12
import test from 'ava';
23
import Vinyl from 'vinyl';
3-
import m from '.';
4+
import {pEvent} from 'p-event';
5+
import stripCssComments from './index.js';
46

5-
test.cb(t => {
6-
const stream = m();
7+
test('main', async t => {
8+
const stream = stripCssComments({whitespace: true});
9+
const dataPromise = pEvent(stream, 'data');
710

8-
stream.once('data', file => {
9-
t.is(file.contents.toString(), 'body{}');
10-
t.end();
11-
});
11+
stream.end(new Vinyl({
12+
contents: Buffer.from('body{/* d */}'),
13+
}));
14+
15+
const file = await dataPromise;
16+
t.is(file.contents.toString(), 'body{}');
17+
});
18+
19+
test('whitespace option', async t => {
20+
const stream = stripCssComments({whitespace: false});
21+
const dataPromise = pEvent(stream, 'data');
1222

1323
stream.end(new Vinyl({
14-
contents: Buffer.from('body{/**/}')
24+
contents: Buffer.from('body{/* foo */}'),
1525
}));
26+
27+
const file = await dataPromise;
28+
t.is(file.contents.toString(), 'body{}');
1629
});

0 commit comments

Comments
 (0)