-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.wls
executable file
·33 lines (24 loc) · 1006 Bytes
/
install.wls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env wolframscript
$successQ = True;
pacletName = FileBaseName[DirectoryName[$InputFileName]]
(* If any messages are produced, fail with non-zero exit code. *)
Check[
$repoRoot = DirectoryName[$InputFileName];
$latestPacletFiles = MaximalBy[
FileNames[FileNameJoin[{$repoRoot, "*.paclet"}]], FileInformation[#, "LastModificationDate"] &];
If[Length[$latestPacletFiles] == 0,
Print[
"No paclet files *.paclet were found. ",
"Run ./build.wls."];
Exit[1];
];
If[PacletFind[pacletName] =!= {}, PacletUninstall[pacletName]];
(* This works in both 12.0 and 12.1. *)
pacletObjectQ[p_] := PacletObjectQ[p] || Head[p] === PacletManager`Paclet;
If[pacletObjectQ[PacletInstall[First[$latestPacletFiles], "IgnoreVersion" -> True]],
Print["Installed " <> First[$latestPacletFiles] <> ". Run Get[\"" <> pacletName <> "\"] to reload the package."],
Print["Install failed."];
$successQ = False];,
$successQ = False;
];
Exit[If[$successQ, 0, 1]]