mirror of https://github.com/aminya/setup-cpp
feat: add exec-powershell package
This commit is contained in:
parent
2b1515ae6b
commit
46635fc18e
|
@ -11,11 +11,10 @@ temp-*
|
|||
*.tsbuildinfo
|
||||
|
||||
# Build directories
|
||||
./dist/
|
||||
!./dist/setup_cpp.js
|
||||
!./dist/setup_cpp.js.map
|
||||
dist/
|
||||
!./dist/
|
||||
.parcel-cache
|
||||
exe/
|
||||
*.log
|
||||
*.exe
|
||||
.cache/
|
||||
.cache/
|
||||
|
|
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
|
@ -34,7 +34,7 @@
|
|||
"lint.prettier": "prettier --write .",
|
||||
"lint.tsc": "tsc --noEmit | loose-ts-check",
|
||||
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.js",
|
||||
"prepare": "npm run build",
|
||||
"prepare": "pnpm run -r build && pnpm run -w build",
|
||||
"start.docker": "docker run -t setup_cpp .",
|
||||
"start.docker.arch": "docker run -t setup_cpp:arch .",
|
||||
"start.docker.fedora": "docker run -t setup_cpp:fedora .",
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "exec-powershell",
|
||||
"version": "1.0.0",
|
||||
"description": "Run a powershell command.",
|
||||
"homepage": "https://github.com/aminya/setup-cpp",
|
||||
"license": "Apache-2.0",
|
||||
"author": "Amin Yahyaabadi",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"source": "./src/index.ts",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"execa": "^5.1.1",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/which": "^2.0.1"
|
||||
},
|
||||
"keywords": [
|
||||
"powershell",
|
||||
"pwsh",
|
||||
"exec",
|
||||
"execa",
|
||||
"spawn",
|
||||
"system",
|
||||
"github-actions",
|
||||
"github",
|
||||
"actions",
|
||||
"gitlab",
|
||||
"ci"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
import execa from "execa"
|
||||
import which from "which"
|
||||
|
||||
/** The cached powershell path */
|
||||
let powershell: string | undefined
|
||||
|
||||
/**
|
||||
* Execute a powershell command.
|
||||
*
|
||||
* @param command The powershell command to execute
|
||||
* @param startupFlags The optional startup flags to be passed to powershell.
|
||||
*
|
||||
* Defaults to `["-NoProfile", "-NoLogo", "-NonInteractive"]`. This means that the Powershell profile is not sourced first.
|
||||
* @param execOptions The options passed to `execa`.
|
||||
*
|
||||
* Defaults to `{ stdio: "inherit" }`
|
||||
* @note It prefers `pwsh` over `powershell`
|
||||
*/
|
||||
export function execPowershell(
|
||||
command: string,
|
||||
startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"],
|
||||
execOptions: execa.Options = { stdio: "inherit" }
|
||||
) {
|
||||
return execa(getPowerShell(), [...startupFlags, "-c", command], execOptions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the powershell executable.
|
||||
*
|
||||
* @note It prefers `pwsh` over `powershell`
|
||||
* @note It caches the path for the subsequent calls to this function
|
||||
*/
|
||||
export function getPowerShell() {
|
||||
if (powershell === undefined) {
|
||||
const maybePwsh = which.sync("pwsh", { nothrow: true })
|
||||
if (maybePwsh !== null) {
|
||||
powershell = maybePwsh
|
||||
}
|
||||
const maybePowerShell = which.sync("powershell", { nothrow: true })
|
||||
if (maybePowerShell !== null) {
|
||||
powershell = maybePowerShell
|
||||
}
|
||||
}
|
||||
if (powershell === undefined) {
|
||||
throw new Error("Could not find powershell")
|
||||
}
|
||||
return powershell
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": ["./src"]
|
||||
}
|
170
pnpm-lock.yaml
170
pnpm-lock.yaml
|
@ -8,87 +8,99 @@ overrides:
|
|||
core-js: '*'
|
||||
babel-eslint: npm:@babel/eslint-parser
|
||||
|
||||
specifiers:
|
||||
'@actions/core': ^1.9.0
|
||||
'@actions/exec': ^1.1.1
|
||||
'@actions/io': ^1.1.2
|
||||
'@actions/tool-cache': ^2.0.1
|
||||
'@types/cross-spawn': ^6.0.2
|
||||
'@types/jest': ^28.1.6
|
||||
'@types/mri': ^1.1.1
|
||||
'@types/node': ^18.6.3
|
||||
'@types/semver': ^7.3.10
|
||||
'@types/which': ^2.0.1
|
||||
caxa: ^2.1.0
|
||||
cross-env: 7.0.3
|
||||
cross-spawn: ^7.0.3
|
||||
cspell: ^6.5.0
|
||||
escape-path-with-spaces: ^1.0.0
|
||||
eslint: ^8.21.0
|
||||
eslint-config-atomic: ^1.18.1
|
||||
execa: ^5.1.1
|
||||
jest: ^28.1.3
|
||||
loose-ts-check: ^1.2.0
|
||||
mri: ^1.2.0
|
||||
msvc-dev-cmd: github:aminya/msvc-dev-cmd#9f672c1
|
||||
npm-check-updates: ^16.0.5
|
||||
npm-run-all2: ^6.0.1
|
||||
numerous: 1.0.3
|
||||
parcel: 2.6.2
|
||||
prettier: 2.7.1
|
||||
prettier-config-atomic: ^3.0.10
|
||||
semver: 7.3.7
|
||||
setup-python: github:actions/setup-python#c474c82340438924daab9282d07300bfe7e3692d
|
||||
shx: 0.3.4
|
||||
terser-config-atomic: ^0.1.1
|
||||
time-delta: github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e
|
||||
ts-jest: ^28.0.7
|
||||
typescript: ^4.7.4
|
||||
ubuntu-version: ^2.0.0
|
||||
untildify: ^4.0.0
|
||||
which: ^2.0.2
|
||||
importers:
|
||||
|
||||
dependencies:
|
||||
'@actions/core': 1.9.0
|
||||
'@actions/exec': 1.1.1
|
||||
'@actions/io': 1.1.2
|
||||
'@actions/tool-cache': 2.0.1
|
||||
escape-path-with-spaces: 1.0.0
|
||||
execa: 5.1.1
|
||||
mri: 1.2.0
|
||||
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
||||
numerous: 1.0.3
|
||||
semver: 7.3.7
|
||||
setup-python: github.com/actions/setup-python/c474c82340438924daab9282d07300bfe7e3692d
|
||||
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
|
||||
ubuntu-version: 2.0.0
|
||||
untildify: 4.0.0
|
||||
which: 2.0.2
|
||||
.:
|
||||
specifiers:
|
||||
'@actions/core': ^1.9.0
|
||||
'@actions/exec': ^1.1.1
|
||||
'@actions/io': ^1.1.2
|
||||
'@actions/tool-cache': ^2.0.1
|
||||
'@types/cross-spawn': ^6.0.2
|
||||
'@types/jest': ^28.1.6
|
||||
'@types/mri': ^1.1.1
|
||||
'@types/node': ^18.6.3
|
||||
'@types/semver': ^7.3.10
|
||||
'@types/which': ^2.0.1
|
||||
caxa: ^2.1.0
|
||||
cross-env: 7.0.3
|
||||
cross-spawn: ^7.0.3
|
||||
cspell: ^6.5.0
|
||||
escape-path-with-spaces: ^1.0.0
|
||||
eslint: ^8.21.0
|
||||
eslint-config-atomic: ^1.18.1
|
||||
execa: ^5.1.1
|
||||
jest: ^28.1.3
|
||||
loose-ts-check: ^1.2.0
|
||||
mri: ^1.2.0
|
||||
msvc-dev-cmd: github:aminya/msvc-dev-cmd#9f672c1
|
||||
npm-check-updates: ^16.0.5
|
||||
npm-run-all2: ^6.0.1
|
||||
numerous: 1.0.3
|
||||
parcel: 2.6.2
|
||||
prettier: 2.7.1
|
||||
prettier-config-atomic: ^3.0.10
|
||||
semver: 7.3.7
|
||||
setup-python: github:actions/setup-python#c474c82340438924daab9282d07300bfe7e3692d
|
||||
shx: 0.3.4
|
||||
terser-config-atomic: ^0.1.1
|
||||
time-delta: github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e
|
||||
ts-jest: ^28.0.7
|
||||
typescript: ^4.7.4
|
||||
ubuntu-version: ^2.0.0
|
||||
untildify: ^4.0.0
|
||||
which: ^2.0.2
|
||||
dependencies:
|
||||
'@actions/core': 1.9.0
|
||||
'@actions/exec': 1.1.1
|
||||
'@actions/io': 1.1.2
|
||||
'@actions/tool-cache': 2.0.1
|
||||
escape-path-with-spaces: 1.0.0
|
||||
execa: 5.1.1
|
||||
mri: 1.2.0
|
||||
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
||||
numerous: 1.0.3
|
||||
semver: 7.3.7
|
||||
setup-python: github.com/actions/setup-python/c474c82340438924daab9282d07300bfe7e3692d
|
||||
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
|
||||
ubuntu-version: 2.0.0
|
||||
untildify: 4.0.0
|
||||
which: 2.0.2
|
||||
devDependencies:
|
||||
'@types/cross-spawn': 6.0.2
|
||||
'@types/jest': 28.1.6
|
||||
'@types/mri': 1.1.1
|
||||
'@types/node': 18.6.3
|
||||
'@types/semver': 7.3.10
|
||||
'@types/which': 2.0.1
|
||||
caxa: 2.1.0
|
||||
cross-env: 7.0.3
|
||||
cross-spawn: 7.0.3
|
||||
cspell: 6.5.0
|
||||
eslint: 8.21.0
|
||||
eslint-config-atomic: 1.18.1
|
||||
jest: 28.1.3_@types+node@18.6.3
|
||||
loose-ts-check: 1.2.0
|
||||
npm-check-updates: 16.0.5
|
||||
npm-run-all2: 6.0.1
|
||||
parcel: 2.6.2
|
||||
prettier: 2.7.1
|
||||
prettier-config-atomic: 3.0.10
|
||||
shx: 0.3.4
|
||||
terser-config-atomic: 0.1.1
|
||||
ts-jest: 28.0.7_bi2kohzqnxavgozw3csgny5hju
|
||||
typescript: 4.7.4
|
||||
|
||||
devDependencies:
|
||||
'@types/cross-spawn': 6.0.2
|
||||
'@types/jest': 28.1.6
|
||||
'@types/mri': 1.1.1
|
||||
'@types/node': 18.6.3
|
||||
'@types/semver': 7.3.10
|
||||
'@types/which': 2.0.1
|
||||
caxa: 2.1.0
|
||||
cross-env: 7.0.3
|
||||
cross-spawn: 7.0.3
|
||||
cspell: 6.5.0
|
||||
eslint: 8.21.0
|
||||
eslint-config-atomic: 1.18.1
|
||||
jest: 28.1.3_@types+node@18.6.3
|
||||
loose-ts-check: 1.2.0
|
||||
npm-check-updates: 16.0.5
|
||||
npm-run-all2: 6.0.1
|
||||
parcel: 2.6.2
|
||||
prettier: 2.7.1
|
||||
prettier-config-atomic: 3.0.10
|
||||
shx: 0.3.4
|
||||
terser-config-atomic: 0.1.1
|
||||
ts-jest: 28.0.7_bi2kohzqnxavgozw3csgny5hju
|
||||
typescript: 4.7.4
|
||||
packages/exec-powershell:
|
||||
specifiers:
|
||||
'@types/which': ^2.0.1
|
||||
execa: ^5.1.1
|
||||
which: ^2.0.2
|
||||
dependencies:
|
||||
execa: 5.1.1
|
||||
which: 2.0.2
|
||||
devDependencies:
|
||||
'@types/which': 2.0.1
|
||||
|
||||
packages:
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
packages:
|
||||
- "./"
|
||||
- "packages/*"
|
|
@ -7,7 +7,11 @@ import { execPowershell } from "../exec/powershell"
|
|||
import { delimiter } from "path"
|
||||
import { escapeSpace } from "../path/escape_space"
|
||||
|
||||
/** An add path function that works locally or inside GitHub Actions */
|
||||
/**
|
||||
* Add an environment variable.
|
||||
*
|
||||
* 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) {
|
||||
const val = shouldEscapeSpace ? escapeSpace(valGiven) : valGiven
|
||||
try {
|
||||
|
@ -27,7 +31,11 @@ export async function addEnv(name: string, valGiven: string | undefined, shouldE
|
|||
}
|
||||
}
|
||||
|
||||
/** An add path function that works locally or inside GitHub Actions */
|
||||
/**
|
||||
* Add a path to the PATH environment variable.
|
||||
*
|
||||
* This function is cross-platforms and works in all the local or CI systems.
|
||||
*/
|
||||
export async function addPath(path: string) {
|
||||
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
|
||||
try {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
"preserveSymlinks": true,
|
||||
"removeComments": false,
|
||||
"skipLibCheck": false,
|
||||
"lib": ["ES2018", "dom"],
|
||||
"target": "ES2018",
|
||||
"lib": ["ES2020", "dom"],
|
||||
"target": "ES2020",
|
||||
"allowJs": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
|
|
Loading…
Reference in New Issue