Do not quote ini values with error constants

This commit is contained in:
Shivam Mathur 2021-02-22 11:44:10 +05:30
parent 1ecc5fdca3
commit 0cc14f65a2
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
3 changed files with 16 additions and 8 deletions

View File

@ -97,12 +97,9 @@ describe('Utils tests', () => {
const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || ''; const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || '';
const script_path: string = path.join(runner_dir, 'test.sh'); const script_path: string = path.join(runner_dir, 'test.sh');
await utils.writeScript('test.sh', testString); await utils.writeScript('test.sh', testString);
await fs.readFile( fs.readFile(script_path, function (error: Error | null, data: Buffer) {
script_path,
function (error: Error | null, data: Buffer) {
expect(testString).toBe(data.toString()); expect(testString).toBe(data.toString());
} });
);
await cleanup(script_path); await cleanup(script_path);
}); });
@ -135,6 +132,17 @@ describe('Utils tests', () => {
'b=3, 4', 'b=3, 4',
'c=5' 'c=5'
]); ]);
expect(await utils.CSVArray('\'a=1,2\', "b=3, 4", c=5, d=~e~')).toEqual([
'a=1,2',
'b=3, 4',
'c=5',
"d='~e~'"
]);
expect(await utils.CSVArray('a=\'1,2\', b="3, 4", c=5')).toEqual([
'a=1,2',
'b=3, 4',
'c=5'
]);
expect(await utils.CSVArray('')).toEqual([]); expect(await utils.CSVArray('')).toEqual([]);
expect(await utils.CSVArray(' ')).toEqual([]); expect(await utils.CSVArray(' ')).toEqual([]);
}); });

2
dist/index.js vendored
View File

@ -1285,7 +1285,7 @@ async function CSVArray(values_csv) {
return value return value
.trim() .trim()
.replace(/^["']|["']$|(?<==)["']/g, '') .replace(/^["']|["']$|(?<==)["']/g, '')
.replace(/=(.*[?{}|&~![()^]+.*)/, "='$1'"); .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'");
}) })
.filter(Boolean); .filter(Boolean);
} }

View File

@ -274,7 +274,7 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
return value return value
.trim() .trim()
.replace(/^["']|["']$|(?<==)["']/g, '') .replace(/^["']|["']$|(?<==)["']/g, '')
.replace(/=(.*[?{}|&~![()^]+.*)/, "='$1'"); .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'");
}) })
.filter(Boolean); .filter(Boolean);
} }