Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Commit

Permalink
Add postinstall scripts which throw an error if the os or cpu is diff…
Browse files Browse the repository at this point in the history
…erent to what the package supports

     This is a required for npm ci to work. npm/cli#558
  • Loading branch information
JakeChampion committed Mar 11, 2020
1 parent 2d3e3b9 commit 2b961f6
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 5 deletions.
5 changes: 4 additions & 1 deletion sass-linux-ia32/package.json
Expand Up @@ -12,5 +12,8 @@
],
"cpu": [
"ia32"
]
],
"scripts": {
"postinstall": "node ./postinstall.js"
}
}
23 changes: 23 additions & 0 deletions sass-linux-ia32/postinstall.js
@@ -0,0 +1,23 @@
"use strict";

const { name, os, cpu } = require("./package.json");

if (os && !os.includes(process.platform)) {
throw new Error(
`${name} does not support the platform you are using. You are using: "${
process.platform
}" and ${name} supports: ${os.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}

if (cpu && !cpu.includes(process.arch)) {
throw new Error(
`${name} does not support the cpu you are using. You are using: "${
process.arch
}" and ${name} supports: ${cpu.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}
5 changes: 4 additions & 1 deletion sass-linux-x64/package.json
Expand Up @@ -12,5 +12,8 @@
],
"cpu": [
"x64"
]
],
"scripts": {
"postinstall": "node ./postinstall.js"
}
}
23 changes: 23 additions & 0 deletions sass-linux-x64/postinstall.js
@@ -0,0 +1,23 @@
"use strict";

const { name, os, cpu } = require("./package.json");

if (os && !os.includes(process.platform)) {
throw new Error(
`${name} does not support the platform you are using. You are using: "${
process.platform
}" and ${name} supports: ${os.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}

if (cpu && !cpu.includes(process.arch)) {
throw new Error(
`${name} does not support the cpu you are using. You are using: "${
process.arch
}" and ${name} supports: ${cpu.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}
5 changes: 4 additions & 1 deletion sass-macos-x64/package.json
Expand Up @@ -9,5 +9,8 @@
},
"os": [
"darwin"
]
],
"scripts": {
"postinstall": "node ./postinstall.js"
}
}
23 changes: 23 additions & 0 deletions sass-macos-x64/postinstall.js
@@ -0,0 +1,23 @@
"use strict";

const { name, os, cpu } = require("./package.json");

if (os && !os.includes(process.platform)) {
throw new Error(
`${name} does not support the platform you are using. You are using: "${
process.platform
}" and ${name} supports: ${os.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}

if (cpu && !cpu.includes(process.arch)) {
throw new Error(
`${name} does not support the cpu you are using. You are using: "${
process.arch
}" and ${name} supports: ${cpu.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}
5 changes: 4 additions & 1 deletion sass-windows-ia32/package.json
Expand Up @@ -12,5 +12,8 @@
],
"cpu": [
"ia32"
]
],
"scripts": {
"postinstall": "node ./postinstall.js"
}
}
23 changes: 23 additions & 0 deletions sass-windows-ia32/postinstall.js
@@ -0,0 +1,23 @@
"use strict";

const { name, os, cpu } = require("./package.json");

if (os && !os.includes(process.platform)) {
throw new Error(
`${name} does not support the platform you are using. You are using: "${
process.platform
}" and ${name} supports: ${os.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}

if (cpu && !cpu.includes(process.arch)) {
throw new Error(
`${name} does not support the cpu you are using. You are using: "${
process.arch
}" and ${name} supports: ${cpu.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}
5 changes: 4 additions & 1 deletion sass-windows-x64/package.json
Expand Up @@ -12,5 +12,8 @@
],
"cpu": [
"x64"
]
],
"scripts": {
"postinstall": "node ./postinstall.js"
}
}
23 changes: 23 additions & 0 deletions sass-windows-x64/postinstall.js
@@ -0,0 +1,23 @@
"use strict";

const { name, os, cpu } = require("./package.json");

if (os && !os.includes(process.platform)) {
throw new Error(
`${name} does not support the platform you are using. You are using: "${
process.platform
}" and ${name} supports: ${os.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}

if (cpu && !cpu.includes(process.arch)) {
throw new Error(
`${name} does not support the cpu you are using. You are using: "${
process.arch
}" and ${name} supports: ${cpu.join(
","
)}. If you think this is a mistake, please contact Origami or open an issue on https://github.com/Financial-Times/sass/issues`
);
}

0 comments on commit 2b961f6

Please sign in to comment.