mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Retrieve error during project generation
This commit is contained in:
parent
4812f34bd5
commit
83836aa255
@ -9,9 +9,13 @@
|
||||
// Node.js core.
|
||||
const path = require('path');
|
||||
|
||||
|
||||
// Public node modules.
|
||||
const _ = require('lodash');
|
||||
const fetch = require('node-fetch');
|
||||
const { machineIdSync } = require('node-machine-id');
|
||||
const shell = require('shelljs');
|
||||
const os = require('os');
|
||||
|
||||
// Master of ceremonies for generators.
|
||||
const generate = require('strapi-generate');
|
||||
@ -77,22 +81,45 @@ module.exports = function (name, cliArguments) {
|
||||
};
|
||||
}
|
||||
|
||||
const error = (error) => {
|
||||
fetch('https://analytics.strapi.io/track', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
event: 'didNotStartAutomatically',
|
||||
deviceId: machineIdSync(),
|
||||
properties: {
|
||||
error,
|
||||
os: os.type()
|
||||
}
|
||||
}),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
// Return the scope and the response (`error` or `success`).
|
||||
return generate(scope, {
|
||||
|
||||
// Log and exit the REPL in case there is an error
|
||||
// while we were trying to generate the new app.
|
||||
error: function returnError(err) {
|
||||
error(err);
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
},
|
||||
|
||||
success: () => {
|
||||
if (scope.quick) {
|
||||
shell.cd(scope.rootPath);
|
||||
shell.exec('strapi start', {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
try {
|
||||
// Enter inside the project folder.
|
||||
shell.cd(scope.rootPath);
|
||||
// Launch the server.
|
||||
shell.exec('strapi start', {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
} catch (e) {
|
||||
error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user