mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Removes legacy downloadFile and downloadJson in favour of using `node-fetch` - A notification will be displayed if the URL provided results in a status of 404 Signed-off-by: Sebastian Malton <sebastian@malton.name>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import attemptInstallInjectable from "./attempt-install/attempt-install.injectable";
|
|
import path from "path";
|
|
import readFileNotifyInjectable from "./read-file-notify/read-file-notify.injectable";
|
|
|
|
export type AttemptInstalls = (filePaths: string[]) => Promise<void>;
|
|
|
|
const attemptInstallsInjectable = getInjectable({
|
|
id: "attempt-installs",
|
|
|
|
instantiate: (di): AttemptInstalls => {
|
|
const attemptInstall = di.inject(attemptInstallInjectable);
|
|
const readFileNotify = di.inject(readFileNotifyInjectable);
|
|
|
|
return async (filePaths) => {
|
|
await Promise.allSettled(
|
|
filePaths.map(async filePath => {
|
|
const data = await readFileNotify(filePath);
|
|
|
|
if (!data) {
|
|
return;
|
|
}
|
|
|
|
return attemptInstall({
|
|
fileName: path.basename(filePath),
|
|
data,
|
|
});
|
|
}),
|
|
);
|
|
};
|
|
},
|
|
});
|
|
|
|
export default attemptInstallsInjectable;
|