1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | const CMD_CONFIG = 'gcloud config config-helper --format=json'; module.exports = function({ exec, }) { return function getConfig() { return new Promise((resolve, reject) => { exec(CMD_CONFIG, (error, stdout, stderr) => { Iif (error) { reject(error); } else { resolve(stdout.trim()); } }); }) .then(JSON.parse) .then(({credential: {access_token: token}, configuration: {properties: {core: {project: projectId}}}}) => ({projectId, token})); }; } module.exports.CMD_CONFIG = CMD_CONFIG; |