Skip to content

Commit

Permalink
fix: vercel args spliting
Browse files Browse the repository at this point in the history
  • Loading branch information
skyf0l committed Oct 13, 2023
1 parent 616ec26 commit 1f88d62
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
24 changes: 22 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ function addVercelMetadata(key, value, providedArgs) {
return ['-m', `${key}=${value}`];
}


/**
*
* The following regex is used to split the vercelArgs string into an array of arguments.
* It conserves strings wrapped in double quotes, with nested escaped double quotes, as a single argument.
*
* Example:
*
* parseArgs('--env foo="bar baz" "foo=\"bar\" baz"') => ['--env', 'foo="bar baz"', 'foo=\\"bar\\" baz']
*/
function parseArgs() {
const args = [];

for (const match of vercelArgs.matchAll(/[^\s"]*"[^\\"]*(\\.[^\\"]*)*"|[^\s]+/gm)) {
args.push(match[0]);
}
return args;
}

async function vercelDeploy(ref, commit) {
let myOutput = '';
// eslint-disable-next-line no-unused-vars
Expand All @@ -139,10 +158,10 @@ async function vercelDeploy(ref, commit) {
options.cwd = workingDirectory;
}

const providedArgs = vercelArgs.split(/[^\s"']+|"([^"]*)"|'([^']*)'/);
const providedArgs = parseArgs(vercelArgs);

const args = [
...vercelArgs.split(/[^\s"']+|"([^"]*)"|'([^']*)'/),
...providedArgs,
...['-t', vercelToken],
...addVercelMetadata('githubCommitSha', context.sha, providedArgs),
...addVercelMetadata('githubCommitAuthorName', context.actor, providedArgs),
Expand Down Expand Up @@ -370,6 +389,7 @@ async function aliasDomainsToDeployment(deploymentUrl) {
}

async function run() {
core.info('Does it really run ????????????????????????');
core.debug(`action : ${context.action}`);
core.debug(`ref : ${context.ref}`);
core.debug(`eventName : ${context.eventName}`);
Expand Down

0 comments on commit 1f88d62

Please sign in to comment.