From 2e45d3b2737b1ce74cbe744e9eab570ba13a18e8 Mon Sep 17 00:00:00 2001 From: Jordan Mele Date: Sat, 24 Oct 2020 18:11:07 +1100 Subject: [PATCH] Doc improvements, TypeScript refinements. --- changelog.md | 8 +++++--- index.js | 6 +++--- package.json | 6 +++--- readme.md | 26 +++++++++++++------------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/changelog.md b/changelog.md index cb4e567..83bfdbf 100644 --- a/changelog.md +++ b/changelog.md @@ -10,10 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * TypeScript definitions. ### Fixed -* Issues deleting files terminating the stream early despite other deletions potentially still occurring in background. +* File system errors during deletion being reported while other deletions are still in progress, causing the process to appear to "hang" after errors.
+ This issue is typically encountered if a file is removed by something else while unseen files are being deleted. ### Changed -* Only forward slashes supported in glob expression. [globby@10.0.0](https://github.com/sindresorhus/globby/releases/tag/v10.0.0)→[fast-glob@3.0.0](https://github.com/mrmlnc/fast-glob/releases/tag/3.0.0) +* Only forward slashes supported in filter expressions. [globby@10.0.0](https://github.com/sindresorhus/globby/releases/tag/v10.0.0)→[fast-glob@3.0.0](https://github.com/mrmlnc/fast-glob/releases/tag/3.0.0) +* Filter expressions are now passed to fast-glob (through globby) instead of the former node-glob (which use minimatch). Compatibility is high, however there may be some inconsistencies. [globby@8.0.0](https://github.com/sindresorhus/globby/releases/tag/v8.0.0) * Increased minimum NodeJS version from 6 to 10. ## [0.2.0] - 2016-06-19 @@ -37,4 +39,4 @@ _Unknown_ [0.2.0]: https://github.com/hh10k/gulp-prune/releases/tag/v0.2.0 [0.1.2]: https://github.com/hh10k/gulp-prune/releases/tag/v0.1.2 [0.1.1]: https://github.com/hh10k/gulp-prune/releases/tag/v0.1.1 -[0.1.0: https://github.com/hh10k/gulp-prune/releases/tag/v0.1.0 +[0.1.0]: https://github.com/hh10k/gulp-prune/releases/tag/v0.1.0 diff --git a/index.js b/index.js index fd87276..291b56c 100644 --- a/index.js +++ b/index.js @@ -211,8 +211,8 @@ class PruneTransform extends Transform { * @typedef {(dest: string) => PruneTransform} DestFunc * @typedef {(dest: string, options: Options) => PruneTransform} DestWithOptionsFunc * @typedef {(options: OptionsWithDest) => PruneTransform} DestAsOptionsFunc - * @type {DestFunc | DestWithOptionsFunc | DestAsOptionsFunc} - */ + * @type {DestFunc & DestWithOptionsFunc & DestAsOptionsFunc} + */// @ts-ignore module.exports = function prune(dest, options) { // Parse, validate and normalize inputs to handle function overloads verify(arguments.length <= 2, 'too many arguments'); @@ -254,7 +254,7 @@ module.exports = function prune(dest, options) { if (!Array.isArray(options.ext)) { options.ext = [ options.ext ]; } - verify((options.ext instanceof Array && options.ext.every(e => typeof e === 'string')), 'options.ext must be a string or string[]'); + verify(Array.isArray(options.ext) && options.ext.every((/** @type {any} */ e) => typeof e === 'string'), 'options.ext must be a string or string[]'); strictOptions.ext = options.ext.slice(); } diff --git a/package.json b/package.json index 071b0ca..5b5114c 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,7 @@ "eslint": "^7.12.0", "mocha": "^8.2.0", "mock-fs": "^4.13.0", - "typescript": "^4.0.3", - "vinyl": "^2.2.1" + "typescript": "^4.0.3" }, "dependencies": { "@ungap/promise-all-settled": "^1.1.2", @@ -43,6 +42,7 @@ "ansi-colors": "^4.1.1", "fancy-log": "^1.3.3", "globby": "^11.0.1", - "plugin-error": "^1.0.1" + "plugin-error": "^1.0.1", + "vinyl": "^2.2.1" } } diff --git a/readme.md b/readme.md index 5ce02aa..1fb8a17 100644 --- a/readme.md +++ b/readme.md @@ -12,18 +12,18 @@ This example will delete all files in the target directory that do not match a s after transpiling changed files. ```js -var gulp = require('gulp'); -var prune = require('gulp-prune'); -var newer = require('gulp-newer'); -var babel = require('gulp-babel'); +const gulp = require('gulp'); +const prune = require('gulp-prune'); +const newer = require('gulp-newer'); +const babel = require('gulp-babel'); -gulp.task('build', () => { +module.exports.build = () => { return gulp.src('src/**/*.js') .pipe(prune('build/')) .pipe(newer('build/')) .pipe(babel({ presets: [ 'es2015' ] })) .pipe(gulp.dest('build/')); -}); +}; ``` ### Prune with custom mapping @@ -33,13 +33,13 @@ The mapping can be customised if the source and destination file names are diffe This example will prune all .js and .js.map files that aren't from the source .ts files. ```js -var gulp = require('gulp'); -var prune = require('gulp-prune'); -var newer = require('gulp-newer'); -var sourcemaps = require('gulp-sourcemaps'); -var typescript = require('gulp-typescript'); +const gulp = require('gulp'); +const prune = require('gulp-prune'); +const newer = require('gulp-newer'); +const sourcemaps = require('gulp-sourcemaps'); +const typescript = require('gulp-typescript'); -gulp.task('build', () => { +module.exports.build = () => { return gulp.src('src/**/*.ts') .pipe(prune({ dest: 'build/', ext: [ '.js', '.js.map' ] })) .pipe(newer({ dest: 'build/', ext: '.js' })) @@ -47,7 +47,7 @@ gulp.task('build', () => { .pipe(typescript()) .pipe(sourcemaps.write('.')) .pipe(gulp.dest('build/')); -}); +} ``` ## API