feat: add untildify-user package

This commit is contained in:
Amin Yahyaabadi 2022-08-07 20:04:59 -07:00
parent a0ead740f7
commit b4a83891fb
16 changed files with 62 additions and 21 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/setup_cpp.mjs vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -68,7 +68,7 @@
"setup-python": "github:actions/setup-python#c474c82340438924daab9282d07300bfe7e3692d",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ubuntu-version": "^2.0.0",
"untildify": "^4.0.0",
"untildify-user": "workspace:*",
"which": "^2.0.2"
},
"devDependencies": {

View File

@ -6,7 +6,6 @@
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"scripts": {
"build": "tsc"

View File

@ -6,7 +6,6 @@
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"scripts": {
"build": "tsc"

View File

@ -6,7 +6,6 @@
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"scripts": {
"build": "tsc"

View File

@ -0,0 +1,29 @@
{
"name": "untildify-user",
"version": "1.0.0",
"description": "Untildify a path for the current user",
"homepage": "https://github.com/aminya/setup-cpp",
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/index.js",
"source": "./src/index.ts",
"scripts": {
"build": "tsc"
},
"dependencies": {
"root-tools": "workspace:*",
"untildify": "^4.0.0"
},
"keywords": [
"tilde",
"expansion",
"expand",
"untildify",
"path",
"home",
"directory",
"user",
"shell",
"bash"
]
}

View File

@ -2,7 +2,7 @@ import { join } from "path"
import untildify from "untildify"
import { isSudo } from "root-tools"
export function untildify_user(path: string) {
export function untildifyUser(path: string) {
if (isSudo() && typeof process.env.SUDO_USER === "string") {
// use the user profile even if root
if (process.platform === "darwin") {

View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["./src"]
}

View File

@ -55,7 +55,7 @@ importers:
ts-readme: ^1.1.3
typescript: ^4.7.4
ubuntu-version: ^2.0.0
untildify: ^4.0.0
untildify-user: workspace:*
which: ^2.0.2
dependencies:
'@actions/core': 1.9.0
@ -75,7 +75,7 @@ importers:
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
untildify-user: link:packages/untildify-user
which: 2.0.2
devDependencies:
'@types/cross-spawn': 6.0.2
@ -130,6 +130,14 @@ importers:
devDependencies:
'@types/which': 2.0.1
packages/untildify-user:
specifiers:
root-tools: workspace:*
untildify: ^4.0.0
dependencies:
root-tools: link:../root-tools
untildify: 4.0.0
packages:
/@actions/cache/3.0.0:

View File

@ -14,7 +14,7 @@ import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
import { addVPrefix, removeVPrefix } from "../utils/setup/version"
import { info } from "../utils/io/io"
import { untildify_user } from "../utils/path/untildify"
import { untildifyUser } from "untildify-user"
import { setupNinja } from "../ninja/ninja"
function getDownloadKcovPackageInfo(version: string): PackageInfo {
@ -69,12 +69,12 @@ async function buildKcov(file: string, dest: string) {
async function getCmake() {
let cmake = which.sync("cmake", { nothrow: true })
if (cmake === null) {
const { binDir } = await setupCmake(getVersion("cmake", undefined), join(untildify_user(""), "cmake"), "")
const { binDir } = await setupCmake(getVersion("cmake", undefined), join(untildifyUser(""), "cmake"), "")
cmake = join(binDir, "cmake")
}
const ninja = which.sync("ninja", { nothrow: true })
if (ninja === null) {
await setupNinja(getVersion("ninja", undefined), join(untildify_user(""), "ninja"), "")
await setupNinja(getVersion("ninja", undefined), join(untildifyUser(""), "ninja"), "")
}
return cmake
}

View File

@ -16,7 +16,7 @@ import { setupNinja } from "./ninja/ninja"
import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage"
import { setupPython } from "./python/python"
import mri from "mri"
import { untildify_user as untildify } from "./utils/path/untildify"
import { untildifyUser } from "untildify-user"
import ciDetect from "@npmcli/ci-detect"
import * as timeDelta from "time-delta"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@ -129,7 +129,7 @@ export async function main(args: string[]): Promise<number> {
const arch = opts.architecture ?? process.arch
// the installation dir for the tools that are downloaded directly
const setupCppDir = process.env.SETUP_CPP_DIR ?? untildify("")
const setupCppDir = process.env.SETUP_CPP_DIR ?? untildifyUser("")
// report messages
const successMessages: string[] = []

View File

@ -1,6 +1,6 @@
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
import ciDetect from "@npmcli/ci-detect"
import { untildify_user as untildify } from "../path/untildify"
import { untildifyUser } from "untildify-user"
import { appendFileSync, existsSync, readFileSync } from "fs"
import { error, warning } from "../io/io"
import { execPowershell } from "exec-powershell"
@ -55,7 +55,7 @@ export async function addPath(path: string) {
}
}
export const cpprc_path = untildify(".cpprc")
export const cpprc_path = untildifyUser(".cpprc")
async function addEnvSystem(name: string, valGiven: string | undefined) {
const val = valGiven ?? ""
@ -129,12 +129,12 @@ export function setupCppInProfile() {
try {
// source cpprc in .profile
const profile_path = untildify(".profile")
const profile_path = untildifyUser(".profile")
appendFileSync(profile_path, source_cpprc_string)
info(`${source_cpprc_string} was added to ${profile_path}`)
// source cpprc in .bashrc too
const bashrc_path = untildify(".bashrc")
const bashrc_path = untildifyUser(".bashrc")
appendFileSync(bashrc_path, source_cpprc_string)
info(`${source_cpprc_string} was added to ${bashrc_path}`)
} catch (err) {

View File

@ -28,5 +28,5 @@
"outDir": "./dist"
},
"compileOnSave": false,
"include": ["./src"]
"include": ["./src", "packages/untildify-user/untildify.ts"]
}