Skip to content

Commit a6de62b

Browse files
chore: remove lodash.uniq, add dist/clean scripts, verify-publish, update repository format
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 127afed commit a6de62b

9 files changed

Lines changed: 108 additions & 58 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
run: npm run lint
3131

3232
- name: Build
33-
run: npm run build
33+
run: npm run dist
3434

3535
- name: Test
3636
run: npm test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
node_modules
22
dist
33
coverage
4+
*.tgz
5+
test/verify-publish/node_modules
6+
test/verify-publish/package-lock.json

README.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,42 @@
22

33
[![CI][b-build]][x-actions]
44

5-
Simple REPL for gulp compatible with gulp 3.x and gulp 4.x.
5+
Simple REPL for gulp.
66

77
### usage
88

9-
```js
10-
// gulpfile example
11-
var gulp = require('gulp');
12-
var repl = require('gulp-repl');
9+
```ts
10+
// gulpfile.ts
11+
import gulp from 'gulp';
12+
import repl from 'gulp-repl';
1313

14-
gulp.task('repl-start', function (cb) {
14+
gulp.task('repl-start', (cb) => {
1515
gulp.repl = repl.start(gulp);
16+
cb();
1617
});
1718

18-
gulp.task('repl-stop', function (cb) {
19+
gulp.task('repl-stop', (cb) => {
1920
if (gulp.repl) {
2021
gulp.repl.close(); // same as nodejs.org/api/readline.html#readline_rl_close
2122
}
2223
cb();
2324
});
2425

25-
gulp.task('foo', function (cb) {
26+
gulp.task('foo', (cb) => {
2627
// do foo stuff
2728
cb();
2829
});
2930

30-
gulp.task('bar', function (cb) {
31+
gulp.task('bar', (cb) => {
3132
// do bar stuff
3233
cb();
3334
});
3435

35-
gulp.task('default');
36+
gulp.task('default', gulp.series('foo', 'bar'));
3637
```
3738

39+
> **Note:** For `gulpfile.ts`, ensure `ts-node` or `tsx` is available. Use `gulpfile.js` with `require()` if you prefer plain JavaScript.
40+
3841
Then, on your terminal write:
3942

4043
```
@@ -64,38 +67,38 @@ foo bar default
6467

6568
The module exports an object with the following methods:
6669

67-
```js
68-
var repl = require('gulp-repl');
70+
```ts
71+
import repl from 'gulp-repl';
6972
```
7073

7174
#### repl.add
7275

73-
```js
74-
function add(Gulp gulp)
76+
```ts
77+
add(gulp: Gulp): typeof repl
7578
```
7679

7780
Adds the `gulp` instance tasks for the REPL and _returns_ the module again.
7881

7982
#### repl.remove
8083

81-
```js
82-
function remove(Gulp gulp)
84+
```ts
85+
remove(gulp: Gulp): typeof repl
8386
```
8487

8588
Removes the `gulp` instance tasks from the REPL and _returns_ the module again.
8689

8790
#### repl.reset
8891

89-
```js
90-
function reset()
92+
```ts
93+
reset(): typeof repl
9194
```
9295

9396
Removes all of the previously added instances and _returns_ the module again.
9497

9598
#### repl.get
9699

97-
```js
98-
function get(Gulp gulp)
100+
```ts
101+
get(gulp?: Gulp): ReplInstance[] | ReplInstance | null
99102
```
100103

101104
Takes a `gulp` instance as argument.
@@ -107,8 +110,8 @@ _returns_
107110

108111
#### repl.start
109112

110-
```js
111-
function start(Gulp gulp)
113+
```ts
114+
start(gulp?: Gulp): readline.Interface
112115
```
113116

114117
Takes a `gulp` instance as argument.

license

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

package.json

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"name": "gulp-repl",
33
"version": "3.0.0",
4-
"description": "a simple repl for gulp",
4+
"description": "A simple repl for gulp",
55
"author": "Javier Carrillo <stringparser@gmail.com>",
66
"license": "MIT",
7-
"repository": "https://github.com/stringparser/gulp-repl",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/stringparser/gulp-repl.git"
10+
},
811
"keywords": [
912
"gulp",
1013
"repl",
@@ -18,27 +21,30 @@
1821
"dist"
1922
],
2023
"scripts": {
21-
"build": "tsc -p tsconfig.build.json",
24+
"dist": "tsc -p tsconfig.build.json",
2225
"lint": "eslint src test",
2326
"test": "jest",
24-
"prepare": "npm run build"
25-
},
26-
"dependencies": {
27-
"lodash.uniq": "4.5.0"
27+
"posttest": "npm run verify:publish",
28+
"verify:publish": "bash test/verify-publish/test.sh",
29+
"prepublishOnly": "npm run dist",
30+
"clean": "rm -rf test/verify-publish/node_modules test/verify-publish/package-lock.json && rm -f *.tgz"
2831
},
2932
"devDependencies": {
3033
"@eslint/js": "9.16.0",
3134
"@types/jest": "^29.5.14",
32-
"@types/lodash.uniq": "4.5.9",
3335
"@types/node": "22.10.1",
3436
"eslint": "9.16.0",
35-
"gulp": "^4.0.2",
37+
"gulp": "5.0.1",
3638
"jest": "29.7.0",
3739
"ts-jest": "29.2.5",
3840
"typescript": "5.7.2",
3941
"typescript-eslint": "8.16.0"
4042
},
4143
"engines": {
42-
"node": ">=14.0.0"
44+
"node": ">=20.0.0"
45+
},
46+
"homepage": "https://github.com/stringparser/gulp-repl",
47+
"bugs": {
48+
"url": "https://github.com/stringparser/gulp-repl/issues"
4349
}
44-
}
50+
}

src/lib.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import uniq from 'lodash.uniq';
2-
31
export interface GulpLike {
42
task?: (name: string, fn?: (cb?: () => void) => void) => void;
53
start?: (...tasks: string[]) => (() => void) | void;
@@ -116,7 +114,7 @@ export function completer(
116114
completion.push(...matches.found);
117115
});
118116

119-
const hits = uniq(completion).filter((elem) => !elem.indexOf(line));
117+
const hits = Array.from(new Set(completion)).filter((elem) => !elem.indexOf(line));
120118

121119
return [hits.length ? hits : completion, line];
122120
}

test/verify-publish/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "gulp-repl-verify",
3+
"private": true,
4+
"type": "module",
5+
"dependencies": {
6+
"gulp": "5.0.1",
7+
"gulp-repl": "file:../../gulp-repl-3.0.0.tgz"
8+
}
9+
}

test/verify-publish/smoke-test.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import replPkg from 'gulp-repl';
2+
import gulp from 'gulp';
3+
4+
const repl = replPkg.default ?? replPkg;
5+
6+
// Create gulp instance and register a task
7+
const gulpInst = gulp;
8+
gulpInst.task('smoke-task', (cb) => {
9+
cb();
10+
});
11+
12+
// Add gulp to repl
13+
repl.add(gulpInst);
14+
15+
// Verify get returns the instance
16+
const instance = repl.get(gulpInst);
17+
if (!instance) throw new Error('Expected instance from get(gulp)');
18+
if (instance.gulp !== gulpInst) throw new Error('Expected instance.gulp to match');
19+
20+
// Verify start returns readline interface
21+
const rl = repl.start(gulpInst);
22+
if (typeof rl.prompt !== 'function') throw new Error('Expected readline Interface with prompt');
23+
24+
// Verify reset
25+
repl.reset();
26+
if (repl.get().length !== 0) throw new Error('Expected empty instances after reset');
27+
28+
console.log('Smoke test passed');

test/verify-publish/test.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
cd "$(dirname "$0")/../.."
4+
5+
echo "Building..."
6+
npm run dist
7+
8+
echo "Packing..."
9+
npm pack
10+
TARBALL="gulp-repl-$(node -p "require('./package.json').version").tgz"
11+
12+
echo "Installing in test/verify-publish..."
13+
cd test/verify-publish
14+
npm install "../../${TARBALL}"
15+
cd ../..
16+
17+
echo "Running smoke test..."
18+
node test/verify-publish/smoke-test.mjs
19+
20+
echo "Cleaning up..."
21+
rm -f "${TARBALL}"
22+
rm -rf test/verify-publish/node_modules test/verify-publish/package-lock.json
23+
24+
echo "verify:publish passed"

0 commit comments

Comments
 (0)