Merge pull request #320 from mandie722/JENKINS-53589_rm_plugin_dirs
[JENKINS-53589] delete exploded plugin dirs
This commit is contained in:
commit
9ce2d9bbb4
|
@ -1,6 +1,7 @@
|
|||
include ../../node.mk
|
||||
|
||||
PATH:=./node_modules/.bin:../../tools:$(PATH)
|
||||
SHELL := /bin/bash
|
||||
PATH := ./node_modules/.bin:../../tools:$(PATH)
|
||||
|
||||
all:: build
|
||||
|
||||
|
|
|
@ -2473,6 +2473,12 @@
|
|||
"integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=",
|
||||
"dev": true
|
||||
},
|
||||
"dateformat": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.2.tgz",
|
||||
"integrity": "sha1-mk30v/FYrC80vGN6vbFUcWB+Flk=",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz",
|
||||
|
@ -3733,12 +3739,14 @@
|
|||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -3753,17 +3761,20 @@
|
|||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
@ -3880,7 +3891,8 @@
|
|||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
@ -3892,6 +3904,7 @@
|
|||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
@ -3906,6 +3919,7 @@
|
|||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -3913,12 +3927,14 @@
|
|||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
|
@ -3937,6 +3953,7 @@
|
|||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
|
@ -4017,7 +4034,8 @@
|
|||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
@ -4029,6 +4047,7 @@
|
|||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
@ -4150,6 +4169,7 @@
|
|||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
@ -5591,6 +5611,29 @@
|
|||
"sane": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"jest-html-reporter": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/jest-html-reporter/-/jest-html-reporter-2.4.2.tgz",
|
||||
"integrity": "sha512-pQ3FQIauOEu8pi6TIJkizXgk7aTOsAfp9bCu7CWgtBThGqI1/w0VLQiOc/DBra2fIaym6tEoqug0gT3DpbVkLA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"dateformat": "3.0.2",
|
||||
"mkdirp": "0.5.1",
|
||||
"strip-ansi": "3.0.1",
|
||||
"xmlbuilder": "8.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"jest-jasmine2": {
|
||||
"version": "23.6.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-23.6.0.tgz",
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"hoek": "^5.0.4",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"jest": "^23.6.0",
|
||||
"jest-html-reporter": "^2.4.2",
|
||||
"memfs": "^2.9.4",
|
||||
"source-map-loader": "^0.2.4",
|
||||
"style-loader": "^0.23.0",
|
||||
|
@ -86,6 +87,18 @@
|
|||
"functions": 45,
|
||||
"lines": 54
|
||||
}
|
||||
}
|
||||
},
|
||||
"reporters": [
|
||||
"default",
|
||||
[
|
||||
"./node_modules/jest-html-reporter",
|
||||
{
|
||||
"pageTitle": "Distribution Client Test Report",
|
||||
"outputPath": "build/test-report.html",
|
||||
"includeFailureMsg": true,
|
||||
"includeConsoleLog": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
import fs from 'fs';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
import * as logger from 'winston';
|
||||
|
@ -77,11 +77,20 @@ export default class Storage {
|
|||
const pluginPath = this.pluginsDirectory();
|
||||
const retArray = [];
|
||||
plugins.forEach((plugin) => {
|
||||
retArray.push(new Promise((resolve, reject) => {
|
||||
fs.remove(`${pluginPath}/${plugin}`, (err) => {
|
||||
if(err) {
|
||||
logger.debug(`${pluginPath}/${plugin} was not found.`);
|
||||
}
|
||||
logger.info(`${pluginPath}/${plugin} was removed`);
|
||||
resolve(true);
|
||||
});
|
||||
}));
|
||||
retArray.push(new Promise((resolve, reject) => {
|
||||
|
||||
fs.unlink(`${pluginPath}/${plugin}.hpi`, (err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
logger.debug(`${pluginPath}/${plugin}.hpi was not found.`);
|
||||
}
|
||||
logger.info(`${pluginPath}/${plugin}.hpi was deleted`);
|
||||
UI.publish(`Deleted ${plugin}.hpi`);
|
||||
|
|
|
@ -45,22 +45,32 @@ describe('The storage module', () => {
|
|||
});
|
||||
|
||||
describe('removePlugins()', () => {
|
||||
it('should return cleanly on empty plugins', () => {
|
||||
expect(Storage.removePlugins());
|
||||
it('should return cleanly on empty plugins', async () => {
|
||||
expect(() => {
|
||||
Storage.removePlugins();
|
||||
}).not.toThrow();
|
||||
});
|
||||
it('should not error if file not found', async () => {
|
||||
await expect(Storage.removePlugins(['not-found']));
|
||||
expect(() => {
|
||||
Storage.removePlugins(['not-found']);
|
||||
}).not.toThrow();
|
||||
});
|
||||
it('should remove all files in a list', async () => {
|
||||
const filenames = ['first', 'second', 'third', 'fourth'];
|
||||
const pluginPath = Storage.pluginsDirectory();
|
||||
mkdirp.sync(pluginPath);
|
||||
filenames.forEach((filename) => {
|
||||
fs.mkdirSync(`${pluginPath}/${filename}`)
|
||||
h.touchFile(`${pluginPath}/${filename}/testfile`); // make sure we remove a directory with files
|
||||
h.touchFile(`${pluginPath}/${filename}.hpi`);
|
||||
expect(h.checkFileExists(`${pluginPath}/${filename}`)).toBeTruthy();
|
||||
expect(h.checkFileExists(`${pluginPath}/${filename}/testfile`)).toBeTruthy();
|
||||
expect(h.checkFileExists(`${pluginPath}/${filename}.hpi`)).toBeTruthy();
|
||||
});
|
||||
await Storage.removePlugins(filenames);
|
||||
filenames.forEach((filename) => {
|
||||
expect(h.checkFileExists(`${pluginPath}/${filename}/testfile`)).toBeFalsy();
|
||||
expect(h.checkFileExists(`${pluginPath}/${filename}`)).toBeFalsy();
|
||||
expect(h.checkFileExists(`${pluginPath}/${filename}.hpi`)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue