mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Add npm scripts for slStats
This commit is contained in:
parent
93a0fa2985
commit
daa223a2fc
@ -161,7 +161,10 @@ class Utils {
|
||||
return servicePath;
|
||||
}
|
||||
|
||||
logStat(serverless) {
|
||||
logStat(serverless, context) {
|
||||
// the context in which serverless was executed (e.g. "install", "usage", "uninstall", ...)
|
||||
context = context || 'usage'; //eslint-disable-line
|
||||
|
||||
const log = (data) => {
|
||||
const writeKey = 'XXXX'; // TODO: Replace me before release
|
||||
const auth = `${writeKey}:`;
|
||||
@ -326,6 +329,7 @@ class Utils {
|
||||
},
|
||||
general: {
|
||||
userId,
|
||||
context,
|
||||
timestamp: (new Date()).getTime(),
|
||||
timezone: (new Date()).toString().match(/([A-Z]+[+-][0-9]+)/)[1],
|
||||
operatingSystem: process.platform,
|
||||
|
||||
@ -51,7 +51,9 @@
|
||||
"lint": "eslint .",
|
||||
"docs": "node scripts/generate-readme.js",
|
||||
"simple-integration-test": "jest --maxWorkers=5 simple-suite",
|
||||
"complex-integration-test": "jest --maxWorkers=5 integration"
|
||||
"complex-integration-test": "jest --maxWorkers=5 integration",
|
||||
"postinstall": "node ./scripts/postinstall.js",
|
||||
"postuninstall": "node ./scripts/postuninstall.js"
|
||||
},
|
||||
"jest": {
|
||||
"testRegex": "(\\.|/)(tests)\\.js$",
|
||||
|
||||
10
scripts/postinstall.js
Normal file
10
scripts/postinstall.js
Normal file
@ -0,0 +1,10 @@
|
||||
const BbPromise = require('bluebird');
|
||||
const Serverless = require('../lib/Serverless');
|
||||
|
||||
const serverless = new Serverless();
|
||||
|
||||
(() => {
|
||||
serverless.init().then(() => {
|
||||
serverless.utils.logStat(serverless, 'install').catch(() => BbPromise.resolve());
|
||||
});
|
||||
})();
|
||||
10
scripts/postuninstall.js
Normal file
10
scripts/postuninstall.js
Normal file
@ -0,0 +1,10 @@
|
||||
const BbPromise = require('bluebird');
|
||||
const Serverless = require('../lib/Serverless');
|
||||
|
||||
const serverless = new Serverless();
|
||||
|
||||
(() => {
|
||||
serverless.init().then(() => {
|
||||
serverless.utils.logStat(serverless, 'uninstall').catch(() => BbPromise.resolve());
|
||||
});
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user