mirror of
https://github.com/strapi/strapi.git
synced 2025-11-11 15:49:50 +00:00
Retrieve error during project generation
This commit is contained in:
parent
4812f34bd5
commit
83836aa255
@ -9,9 +9,13 @@
|
|||||||
// Node.js core.
|
// Node.js core.
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
|
||||||
// Public node modules.
|
// Public node modules.
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
const { machineIdSync } = require('node-machine-id');
|
||||||
const shell = require('shelljs');
|
const shell = require('shelljs');
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
// Master of ceremonies for generators.
|
// Master of ceremonies for generators.
|
||||||
const generate = require('strapi-generate');
|
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 the scope and the response (`error` or `success`).
|
||||||
return generate(scope, {
|
return generate(scope, {
|
||||||
|
|
||||||
// Log and exit the REPL in case there is an error
|
// Log and exit the REPL in case there is an error
|
||||||
// while we were trying to generate the new app.
|
// while we were trying to generate the new app.
|
||||||
error: function returnError(err) {
|
error: function returnError(err) {
|
||||||
|
error(err);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
success: () => {
|
success: () => {
|
||||||
if (scope.quick) {
|
if (scope.quick) {
|
||||||
|
try {
|
||||||
|
// Enter inside the project folder.
|
||||||
shell.cd(scope.rootPath);
|
shell.cd(scope.rootPath);
|
||||||
|
// Launch the server.
|
||||||
shell.exec('strapi start', {
|
shell.exec('strapi start', {
|
||||||
stdio: 'inherit'
|
stdio: 'inherit'
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user