serverless/lib/utils/getCacheFilePath.js
Erik Erikson 553e6cf0da Provide Consistent Service Path
Fix #5242

Do this by first supplying the `servicePath` in `~/lib/plugins/lib/validate.js` and `~/lib/plugins/print.js` in a consistent manner with the code in `~/lib/classes/PluginManager.js`.  Then, provide a default of `process.cwd()` for `servicePath` in `getCacheFilePath` and `getServerlessConfigFile`.
2018-09-19 17:03:29 -07:00

14 lines
436 B
JavaScript

'use strict';
const homedir = require('os').homedir();
const path = require('path');
const crypto = require('crypto');
const getCacheFilePath = function (srvcPath) {
const servicePath = srvcPath || process.cwd();
const servicePathHash = crypto.createHash('sha256').update(servicePath).digest('hex');
return path.join(homedir, '.serverless', 'cache', servicePathHash, 'autocomplete.json');
};
module.exports = getCacheFilePath;