mirror of https://github.com/aminya/setup-cpp
fix: quote the environment variables before adding
This commit is contained in:
parent
740f226722
commit
70c228ecc9
|
@ -19,7 +19,7 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
|
||||||
| compiler and analyzer | llvm, gcc, msvc, vcvarsall, cppcheck, clangtidy, clangformat |
|
| compiler and analyzer | llvm, gcc, msvc, vcvarsall, cppcheck, clangtidy, clangformat |
|
||||||
| build system | cmake, ninja, meson, make, task, bazel |
|
| build system | cmake, ninja, meson, make, task, bazel |
|
||||||
| package manager | vcpkg, conan, choco, brew, nala |
|
| package manager | vcpkg, conan, choco, brew, nala |
|
||||||
| cache | cppcache |
|
| cache | cppcache, sccache |
|
||||||
| documentation | doxygen, graphviz |
|
| documentation | doxygen, graphviz |
|
||||||
| coverage | gcovr, opencppcoverage, kcov |
|
| coverage | gcovr, opencppcoverage, kcov |
|
||||||
| other | python, powershell, sevenzip |
|
| other | python, powershell, sevenzip |
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -58,6 +58,7 @@
|
||||||
"admina": "^0.1.3",
|
"admina": "^0.1.3",
|
||||||
"ci-log": "workspace:1.0.0",
|
"ci-log": "workspace:1.0.0",
|
||||||
"escape-path-with-spaces": "github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3",
|
"escape-path-with-spaces": "github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3",
|
||||||
|
"escape-quotes": "^1.0.2",
|
||||||
"exec-powershell": "workspace:1.0.0",
|
"exec-powershell": "workspace:1.0.0",
|
||||||
"execa": "^5.1.1",
|
"execa": "^5.1.1",
|
||||||
"is-url-online": "^1.5.0",
|
"is-url-online": "^1.5.0",
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
|
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
|
||||||
"numerous": "1.0.3",
|
"numerous": "1.0.3",
|
||||||
"patha": "^0.4.1",
|
"patha": "^0.4.1",
|
||||||
|
"quote-unquote": "^1.0.0",
|
||||||
"semver": "7.3.8",
|
"semver": "7.3.8",
|
||||||
"setup-python": "github:actions/setup-python#v4.3.0",
|
"setup-python": "github:actions/setup-python#v4.3.0",
|
||||||
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
|
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
|
||||||
|
|
|
@ -30,6 +30,7 @@ importers:
|
||||||
cross-spawn: ^7.0.3
|
cross-spawn: ^7.0.3
|
||||||
cspell: ^6.14.3
|
cspell: ^6.14.3
|
||||||
escape-path-with-spaces: github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3
|
escape-path-with-spaces: github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3
|
||||||
|
escape-quotes: ^1.0.2
|
||||||
eslint: ^8.28.0
|
eslint: ^8.28.0
|
||||||
eslint-config-atomic: ^1.18.1
|
eslint-config-atomic: ^1.18.1
|
||||||
exec-powershell: workspace:1.0.0
|
exec-powershell: workspace:1.0.0
|
||||||
|
@ -46,6 +47,7 @@ importers:
|
||||||
patha: ^0.4.1
|
patha: ^0.4.1
|
||||||
prettier: 2.7.1
|
prettier: 2.7.1
|
||||||
prettier-config-atomic: ^3.1.0
|
prettier-config-atomic: ^3.1.0
|
||||||
|
quote-unquote: ^1.0.0
|
||||||
readme-md-generator: ^1.0.0
|
readme-md-generator: ^1.0.0
|
||||||
semver: 7.3.8
|
semver: 7.3.8
|
||||||
setup-python: github:actions/setup-python#v4.3.0
|
setup-python: github:actions/setup-python#v4.3.0
|
||||||
|
@ -69,6 +71,7 @@ importers:
|
||||||
admina: 0.1.3
|
admina: 0.1.3
|
||||||
ci-log: link:packages/ci-log
|
ci-log: link:packages/ci-log
|
||||||
escape-path-with-spaces: github.com/aminya/escape-path-with-spaces/d9f81ee649203ddc55783a2f96ada59df06118e3
|
escape-path-with-spaces: github.com/aminya/escape-path-with-spaces/d9f81ee649203ddc55783a2f96ada59df06118e3
|
||||||
|
escape-quotes: 1.0.2
|
||||||
exec-powershell: link:packages/exec-powershell
|
exec-powershell: link:packages/exec-powershell
|
||||||
execa: 5.1.1
|
execa: 5.1.1
|
||||||
is-url-online: 1.5.0
|
is-url-online: 1.5.0
|
||||||
|
@ -76,6 +79,7 @@ importers:
|
||||||
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
||||||
numerous: 1.0.3
|
numerous: 1.0.3
|
||||||
patha: 0.4.1
|
patha: 0.4.1
|
||||||
|
quote-unquote: 1.0.0
|
||||||
semver: 7.3.8
|
semver: 7.3.8
|
||||||
setup-python: github.com/actions/setup-python/13ae5bb136fac2878aff31522b9efb785519f984
|
setup-python: github.com/actions/setup-python/13ae5bb136fac2878aff31522b9efb785519f984
|
||||||
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
|
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
|
||||||
|
@ -4202,10 +4206,15 @@ packages:
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/escape-quotes/1.0.2:
|
||||||
|
resolution: {integrity: sha512-JpLFzklNReeakCpyj59s78P5F72q0ZUpDnp2BuIk9TtTjj2HMsgiWBChw17BlZT8dRhMtmSb1jE2+pTP1iFYyw==}
|
||||||
|
dependencies:
|
||||||
|
escape-string-regexp: 1.0.5
|
||||||
|
dev: false
|
||||||
|
|
||||||
/escape-string-regexp/1.0.5:
|
/escape-string-regexp/1.0.5:
|
||||||
resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==}
|
resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==}
|
||||||
engines: {node: '>=0.8.0'}
|
engines: {node: '>=0.8.0'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/escape-string-regexp/2.0.0:
|
/escape-string-regexp/2.0.0:
|
||||||
resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==}
|
resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==}
|
||||||
|
@ -8100,6 +8109,10 @@ packages:
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/quote-unquote/1.0.0:
|
||||||
|
resolution: {integrity: sha512-twwRO/ilhlG/FIgYeKGFqyHhoEhqgnKVkcmqMKi2r524gz3ZbDTcyFt38E9xjJI2vT+KbRNHVbnJ/e0I25Azwg==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/rc-config-loader/4.1.1:
|
/rc-config-loader/4.1.1:
|
||||||
resolution: {integrity: sha512-S10o85x/szboh7FOxUyU+KuED+gr9V7SEnUBOzSn+vd1K8J2MtkP1RCPWg8Sw5kkuZKr7976bFzacCM6QtAApQ==}
|
resolution: {integrity: sha512-S10o85x/szboh7FOxUyU+KuED+gr9V7SEnUBOzSn+vd1K8J2MtkP1RCPWg8Sw5kkuZKr7976bFzacCM6QtAApQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { execPowershell } from "exec-powershell"
|
||||||
import { delimiter } from "path"
|
import { delimiter } from "path"
|
||||||
import escapeSpace from "escape-path-with-spaces"
|
import escapeSpace from "escape-path-with-spaces"
|
||||||
import { giveUserAccess } from "user-access"
|
import { giveUserAccess } from "user-access"
|
||||||
|
import escapeQuote from "escape-quotes"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an environment variable.
|
* Add an environment variable.
|
||||||
|
@ -14,7 +15,7 @@ import { giveUserAccess } from "user-access"
|
||||||
* This function is cross-platforms and works in all the local or CI systems.
|
* This function is cross-platforms and works in all the local or CI systems.
|
||||||
*/
|
*/
|
||||||
export async function addEnv(name: string, valGiven: string | undefined, shouldEscapeSpace: boolean = false) {
|
export async function addEnv(name: string, valGiven: string | undefined, shouldEscapeSpace: boolean = false) {
|
||||||
const val = shouldEscapeSpace ? escapeSpace(valGiven ?? "") : valGiven
|
const val = escapeString(valGiven ?? "", shouldEscapeSpace)
|
||||||
try {
|
try {
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
try {
|
try {
|
||||||
|
@ -32,6 +33,11 @@ export async function addEnv(name: string, valGiven: string | undefined, shouldE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escapeString(valGiven: string, shouldEscapeSpace: boolean = false) {
|
||||||
|
const spaceEscaped = shouldEscapeSpace ? escapeSpace(valGiven) : valGiven ?? ""
|
||||||
|
return escapeQuote(spaceEscaped, '"', "\\")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a path to the PATH environment variable.
|
* Add a path to the PATH environment variable.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
/** Escape `'` with `\\` */
|
||||||
|
declare function escapeQuote(input: string): string
|
||||||
|
/** Escape the given character with the given escape character */
|
||||||
|
declare function escapeQuote(input: string, character: string, escape_character: string): string
|
||||||
|
|
||||||
|
declare module "escape-quotes" {
|
||||||
|
export = escapeQuote
|
||||||
|
}
|
Loading…
Reference in New Issue