Skip to content

Commit

Permalink
fix: use own, newly created directory
Browse files Browse the repository at this point in the history
Closes #129
  • Loading branch information
mstruebing committed Oct 9, 2024
1 parent 95d9135 commit dd8c7fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
100644 → 100755

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@ import path from 'node:path'
import { findRelease } from './release'
import { checkerName, version } from './shared'

const WORKING_DIR = path.join(process.env.HOME ?? "/tmp", 'editorconfig-checker')

async function main() {
info(`Find '${version}' release`)
const release = await findRelease(version)

info(`Downloading '${release.name}'`)
const archivePath = await downloadTool(release.browser_download_url)

info(`Create '${WORKING_DIR}' directory`)
await fs.mkdir(path.join(WORKING_DIR), { recursive: true })


info(`Extracting '${release.name}'`)
const extractedPath = await extractTar(archivePath, process.env.HOME)
const extractedPath = await extractTar(archivePath, WORKING_DIR)
const cwd = path.join(extractedPath, 'bin')

const [name] = await fs.readdir(cwd)
const renamedName = path.format({
name: checkerName,
ext: path.extname(name),
})

info(`Rename '${name}' to '${renamedName}'`)
await fs.chmod(path.join(cwd, name), 0o755)
await fs.rename(path.join(cwd, name), path.join(cwd, renamedName))

info('Add to PATH')
addPath(cwd)
}
Expand Down

0 comments on commit dd8c7fe

Please sign in to comment.