2020-02-14 00:52:16 +01:00
|
|
|
/*
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-12-14 15:32:27 +01:00
|
|
|
import path from 'path';
|
|
|
|
import rimraf from 'rimraf';
|
2022-01-10 13:57:33 +01:00
|
|
|
|
2021-12-14 15:32:27 +01:00
|
|
|
import { DependencyInfo } from './dep';
|
|
|
|
import HakEnv from './hakEnv';
|
2020-02-14 00:52:16 +01:00
|
|
|
|
2021-12-14 15:32:27 +01:00
|
|
|
export default async function clean(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
|
|
|
|
await new Promise<void>((resolve, reject) => {
|
2022-12-05 12:50:49 +01:00
|
|
|
rimraf(moduleInfo.moduleDotHakDir, (err?: Error | null) => {
|
2020-02-14 00:52:16 +01:00
|
|
|
if (err) {
|
|
|
|
reject(err);
|
|
|
|
} else {
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-12-14 15:32:27 +01:00
|
|
|
await new Promise<void>((resolve, reject) => {
|
2022-12-05 12:50:49 +01:00
|
|
|
rimraf(path.join(hakEnv.dotHakDir, 'links', moduleInfo.name), (err?: Error | null) => {
|
2020-02-14 00:52:16 +01:00
|
|
|
if (err) {
|
|
|
|
reject(err);
|
|
|
|
} else {
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-12-14 15:32:27 +01:00
|
|
|
await new Promise<void>((resolve, reject) => {
|
2022-12-05 12:50:49 +01:00
|
|
|
rimraf(path.join(hakEnv.projectRoot, 'node_modules', moduleInfo.name), (err?: Error | null) => {
|
2020-02-14 00:52:16 +01:00
|
|
|
if (err) {
|
|
|
|
reject(err);
|
|
|
|
} else {
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|