Skip to content

Commit

Permalink
add preinstall check
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyNikiforov authored Apr 13, 2024
1 parent c9b8c5f commit 088242e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions npm/icloudpd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"bin": {
"icloudpd": "bin/icloudpd.js"
},
"scripts": {
"preinstall": "node preinstall.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/icloud_photos_downloader/icloud_photos_downloader.git"
Expand Down
40 changes: 40 additions & 0 deletions npm/icloudpd/preinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env node
"use strict";
var os = require("os");
var fs = require("fs");
var platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
var knownPlatforms = {
"linux x64 LE": {
"pkgName": "@icloudpd/linux-x64",
"subPath": "bin/icloudpd"
},
"linux ia32 LE": {
"pkgName": "@icloudpd/linux-ia32",
"subPath": "bin/icloudpd"
},
"linux arm64 LE": {
"pkgName": "@icloudpd/linux-arm64",
"subPath": "bin/icloudpd"
},
"linux arm LE": {
"pkgName": "@icloudpd/linux-arm",
"subPath": "bin/icloudpd"
},
"darwin x64 LE": {
"pkgName": "@icloudpd/darwin-x64",
"subPath": "bin/icloudpd"
},
"darwin arm64 LE": {
"pkgName": "@icloudpd/darwin-arm64",
"subPath": "bin/icloudpd"
},
"win32 x64 LE": {
"pkgName": "@icloudpd/win32-x64",
"subPath": "bin/icloudpd.exe"
}
};
if (platformKey in knownPlatforms) {
// all good to proceed
} else {
throw new Error(`Unsupported platform: '${platformKey}'`);
}

0 comments on commit 088242e

Please sign in to comment.