esbuild-plugin-clean
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "esbuild-plugin-clean", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "ESBuild plugin for cleaning up assets before building.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const esbuild_plugin_clean_1 = tslib_1.__importDefault(require("./lib/esbuild-plugin-clean")); | ||
const esbuild_plugin_clean_1 = __importDefault(require("./lib/esbuild-plugin-clean")); | ||
exports.default = esbuild_plugin_clean_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,67 +0,51 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const tslib_1 = require('tslib'); | ||
const chalk_1 = tslib_1.__importDefault(require('chalk')); | ||
const del_1 = tslib_1.__importDefault(require('del')); | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const del_1 = __importDefault(require("del")); | ||
exports.default = (options = {}) => { | ||
console.log('options: ', options); | ||
var _a, _b, _c, _d, _e; | ||
const patterns = (_a = options.patterns) !== null && _a !== void 0 ? _a : []; | ||
const dryRun = (_b = options.dryRun) !== null && _b !== void 0 ? _b : false; | ||
const delOptions = (_c = options.options) !== null && _c !== void 0 ? _c : {}; | ||
const sync = (_d = options.sync) !== null && _d !== void 0 ? _d : true; | ||
const cleanOn = | ||
(_e = options.cleanOn) !== null && _e !== void 0 ? _e : 'start'; | ||
const logCleanFiles = (cleanFiles) => { | ||
if (dryRun) { | ||
console.log( | ||
chalk_1.default.blue('i'), | ||
`Clean plugin invoked in dryRun mode` | ||
); | ||
} | ||
if (cleanFiles.length) { | ||
console.log( | ||
chalk_1.default.blue('i'), | ||
`File Cleaned:\n${cleanFiles.join('\n')}` | ||
); | ||
} | ||
}; | ||
const handler = sync | ||
? () => { | ||
const cleanFiles = del_1.default.sync( | ||
patterns, | ||
Object.assign({ dryRun }, delOptions) | ||
); | ||
logCleanFiles(cleanFiles); | ||
} | ||
: () => { | ||
del_1 | ||
.default(patterns, Object.assign({ dryRun }, delOptions)) | ||
.then((cleanFiles) => { | ||
var _a, _b, _c, _d, _e; | ||
const patterns = (_a = options.patterns) !== null && _a !== void 0 ? _a : []; | ||
const dryRun = (_b = options.dryRun) !== null && _b !== void 0 ? _b : false; | ||
const delOptions = (_c = options.options) !== null && _c !== void 0 ? _c : {}; | ||
const sync = (_d = options.sync) !== null && _d !== void 0 ? _d : true; | ||
const cleanOn = (_e = options.cleanOn) !== null && _e !== void 0 ? _e : 'start'; | ||
const logCleanFiles = (cleanFiles) => { | ||
if (dryRun) { | ||
console.log(chalk_1.default.blue('i'), `Clean plugin invoked in dryRun mode`); | ||
} | ||
if (cleanFiles.length) { | ||
console.log(chalk_1.default.blue('i'), `File Cleaned:\n${cleanFiles.join('\n')}`); | ||
} | ||
}; | ||
const handler = sync | ||
? () => { | ||
const cleanFiles = del_1.default.sync(patterns, Object.assign({ dryRun }, delOptions)); | ||
logCleanFiles(cleanFiles); | ||
}); | ||
}; | ||
return { | ||
name: 'esbuild:clean', | ||
setup({ | ||
initialOptions, | ||
onStart: registerOnStartCallback, | ||
onEnd: registerOnEndCallback, | ||
}) { | ||
if (!patterns.length) { | ||
return; | ||
} | ||
if (cleanOn === 'start' || cleanOn === 'both') { | ||
registerOnStartCallback(() => { | ||
handler(); | ||
}); | ||
} | ||
if (cleanOn === 'end' || cleanOn === 'both') { | ||
registerOnEndCallback(() => { | ||
handler(); | ||
}); | ||
} | ||
}, | ||
}; | ||
} | ||
: () => { | ||
del_1.default(patterns, Object.assign({ dryRun }, delOptions)).then((cleanFiles) => { | ||
logCleanFiles(cleanFiles); | ||
}); | ||
}; | ||
return { | ||
name: 'esbuild:clean', | ||
setup({ initialOptions, onStart: registerOnStartCallback, onEnd: registerOnEndCallback, }) { | ||
if (!patterns.length) { | ||
return; | ||
} | ||
if (cleanOn === 'start' || cleanOn === 'both') { | ||
registerOnStartCallback(() => { | ||
handler(); | ||
}); | ||
} | ||
if (cleanOn === 'end' || cleanOn === 'both') { | ||
registerOnEndCallback(() => { | ||
handler(); | ||
}); | ||
} | ||
}, | ||
}; | ||
}; | ||
//# sourceMappingURL=esbuild-plugin-clean.js.map |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5130
6
71