cmd.run in lifecycle hooks strapi
Code below working on development mode, but in production, it throws premission error
CMS: Strapi.io
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/models.html#lifecycle-hooks)
* to customize this model
*/
const cmd = require('node-cmd');
module.exports = {
lifecycles: {
afterCreate() {
cmd.run('cd /var/www/example.com/html && npm run build');
},
afterUpdate() {
cmd.run('cd /var/www/example.com/html && npm run build');
},
afterDelete() {
cmd.run('cd /var/www/example.com/html && npm run build');
},
},
};
Error:
> [email protected] build /var/www/siteName/html
> gatsby build success open and validate gatsby-configs -
0.067s success load plugins - 1.140s success onPreInit -
0.064s success delete html and css files from previous builds -
0.016s [0m [0m [0m [97m [41mError [0m [37m [41m: [0m [37m [41m
[0m [97m [41m
EACCES: permission denied, rmdir '/var/www/siteName/html/.cac
[0m [0m [97m [41mhe/webpack'
[0m [0m success initialize cache - 0.048s [0m [0m [0m [97m [41m
Error [0m [37m [41m: [0m [37m [41m [0m [97m [41mE
ACCES: permission denied, unlink '/var/www/siteName/html/.ca
[0m [0m [97m [41mche/strip-prefix.js' [0m [0m
not finished copy gatsby files - 0.015s