You can define a postinstall
script in your app's package.json :
package.json
{
"name": "my-app",
"version": "1.0.0",
"scripts": {
"start": "node src/index.js",
"postinstall": "node downloadAssets.js", // <--------------------------
// ...
},
"dependencies": { /* ... */ }
// ...
}
And then create a script to do it:
downloadAssets.js
const http = require('http');
const fs = require('fs');
const file = fs.createWriteStream("file.pdf");
http.get("http://download.com/file.pdf", function(response) {
response.pipe(file);
});
It will be executed when you install your app (after everything is installed)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…