jacob-meacham / serverless-plugin-git-variables

:zap: Expose git variables to serverless
MIT License
87 stars 32 forks source link

Not works for Windows #82

Closed cenyG closed 1 year ago

cenyG commented 3 years ago

Hi, I just had some struggling around your pluging, it's still not working for my environment actualy for no reason. But I made some workaround and replace your _exec function:

async function _exec(cmd, options = {
  timeout: 1000
}) {
  return new Promise((resolve, reject) => {
    _child_process.default.exec(cmd, options, (err, stdout) => {
      if (err) {
        reject(err);
      } else {
        resolve(stdout.trim());
      }
    });
  });
}

with this one:

async function _exec(cmd, options = {
  timeout: 1000
}) {
    return _child_process.default.execSync(cmd, { ...options, encoding: 'utf-8' }).trimEnd();
}

and now it's works for me.

I could create MR but I think it's a bit dirty. Just In case you would like to investigate.

My environment:

f00f commented 2 years ago

I work on Win 10 and run serverless from PowerShell. Don't know the node version I'm using (other pc), but should be 16 or 14. The released package works with no problems.