Merge pull request #24224 from bitjson/del

del: arrays are not required to be mutable
This commit is contained in:
Mine Starks
2018-03-23 16:09:45 -07:00
committed by GitHub
2 changed files with 43 additions and 28 deletions

View File

@@ -1,39 +1,47 @@
import del = require("del");
import del = require('del');
let paths = ["build", "dist/**/*.js"];
let paths = ['build', 'dist/**/*.js'];
del(["tmp/*.js", "!tmp/unicorn.js"]);
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
del(["tmp/*.js", "!tmp/unicorn.js"], {dryRun: true});
del(["tmp/*.js", "!tmp/unicorn.js"], {concurrency: 20});
del(["tmp/*.js", "!tmp/unicorn.js"], {cwd: ''});
del(['tmp/*.js', '!tmp/unicorn.js']);
del(['tmp/*.js', '!tmp/unicorn.js'], { force: true });
del(['tmp/*.js', '!tmp/unicorn.js'], { dryRun: true });
del(['tmp/*.js', '!tmp/unicorn.js'], { concurrency: 20 });
del(['tmp/*.js', '!tmp/unicorn.js'], { cwd: '' });
del(["tmp/*.js", "!tmp/unicorn.js"]).then((paths: string[]) => {
del(['tmp/*.js', '!tmp/unicorn.js']).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}).then((paths: string[]) => {
del(['tmp/*.js', '!tmp/unicorn.js'], { force: true }).then(
(paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
}
);
del('tmp/*.js');
del('tmp/*.js', { force: true });
del('tmp/*.js', { dryRun: true });
del('tmp/*.js', { concurrency: 20 });
del('tmp/*.js', { cwd: '' });
del('tmp/*.js').then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del("tmp/*.js");
del("tmp/*.js", {force: true});
del("tmp/*.js", {dryRun: true});
del("tmp/*.js", {concurrency: 20});
del("tmp/*.js", {cwd: ''});
del("tmp/*.js").then((paths: string[]) => {
del('tmp/*.js', { force: true }).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del("tmp/*.js", {force: true}).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
paths = del.sync(['tmp/*.js', '!tmp/unicorn.js']);
paths = del.sync(['tmp/*.js', '!tmp/unicorn.js'], { force: true });
paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"]);
paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
paths = del.sync('tmp/*.js');
paths = del.sync('tmp/*.js', { force: true });
paths = del.sync('tmp/*.js', { dryRun: true });
paths = del.sync('tmp/*.js', { concurrency: 20 });
paths = del.sync('tmp/*.js', { cwd: '' });
paths = del.sync("tmp/*.js");
paths = del.sync("tmp/*.js", {force: true});
paths = del.sync("tmp/*.js", {dryRun: true});
paths = del.sync("tmp/*.js", {concurrency: 20});
paths = del.sync("tmp/*.js", {cwd: ''});
const immutable: ReadonlyArray<string> = ['tmp/*.js', '!tmp/unicorn.js'];
const mutable = del(immutable);
const mutablePaths = del.sync(immutable);
mutable.then(paths => paths.push('test'));
mutablePaths.push('test');

13
types/del/index.d.ts vendored
View File

@@ -3,14 +3,21 @@
// Definitions by: Asana <https://asana.com>
// Aya Morisawa <https://github.com/AyaMorisawa>
// BendingBender <https://github.com/BendingBender>
// Jason Dreyzehner <https://github.com/bitjson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import glob = require("glob");
import glob = require('glob');
declare function del(patterns: string | string[], options?: del.Options): Promise<string[]>;
declare function del(
patterns: string | ReadonlyArray<string>,
options?: del.Options
): Promise<string[]>;
declare namespace del {
function sync(patterns: string | string[], options?: Options): string[];
function sync(
patterns: string | ReadonlyArray<string>,
options?: Options
): string[];
interface Options extends glob.IOptions {
force?: boolean;