[uiBundles/resetBundleDir] force del() if bundleDir is outside cwd (#22981)

The `UiBundlesController.resetBundleDir()` method deletes old bundle assets when necessary using `del()`, which by default limits deletes to directories within `process.cwd`. This is normally very helpful, but in our case we don't want to limit the `optimize.bundleDir` to the current working directory, so we must use the `force: true` config to disable this check.

release notes: Trying to run a Kibana optimization (usually after installing or disabling a plugin) from a directory that is not a parent of the `optimize.bundleDir` configuration or the Kibana installation will no longer fail with "Cannot delete files/folders outside the current working directory".
This commit is contained in:
Spencer 2018-09-13 10:50:53 -07:00 committed by GitHub
parent b879095053
commit 0938382b07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -152,7 +152,12 @@ export class UiBundlesController {
await mkdirpAsync(this._workingDir);
} else {
// delete all children of the working directory
await del(this.resolvePath('*'));
await del(this.resolvePath('*'), {
// since we know that `this.resolvePath()` is going to return an absolute path based on the `optimize.bundleDir`
// and since we don't want to require that users specify a bundleDir that is within the cwd or limit the cwd
// directory used to run Kibana in any way we use force here
force: true
});
}
// write the entry/style files for each bundle