Install npm dependencies based on the OS CPU architecture.
Install the module with: npm install --save npm-arch-dependencies
.
List the specific dependencies for each platform in your package.json
, in the form of os.arch() + 'Dependencies'
.
To include raspi-io
and johnny-five
in arm
only:
"armDependencies": {
"johnny-five": "latest",
"raspi-io": "latest"
}
Then run:
archpm
If you are running the command on a Raspbery Pi archpm
will install raspi-io
and johnny-five
.
Add archpm
to the scripts section of package.json
{
"scripts": {
"postinstall": "archpm",
"start": ...
}
}
In your source code, make sure you are as well importing code based on your architecture.
For example:
const arch = require('os').arch();
class Button {
constructor(config={pin:8}){
if(arch === 'arm'){
const five = require('johnny-five');
this.relay = new five.Relay(config);
} else {
this.relay = {
open: function(){},
close: function(){}
};
}
}
}
Based on the work of bertofer.
Copyright (c) 2016 goliatone
Licensed under the MIT license.