Specify target platform value in postinstall script

Open
#68 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, node.js
Domain
build-system

Research direction

Start at the postinstall script and the getTarget entry point shown in the issue. Check how npm_config_arch is currently handled, then verify that npm_config_platform selects the intended target values for each supported platform and architecture; done means cross-platform builds use the requested platform without changing default behavior.

Written by the indexing model from the issue text.

Description

We can currently specify the arch value using process.env.npm_config_arch, would it be possible to extend that to include the platform attribute. This would be helpful for cross-platform builds.

async function getTarget() {
const arch = process.env.npm_config_arch || os.arch();
const platform = process.env.npm_config_platform || os.platform();

switch (platform) {
    case 'darwin':
        return arch === 'arm64' ? 'aarch64-apple-darwin' :
            'x86_64-apple-darwin';
    case 'win32':
        return arch === 'x64' ? 'x86_64-pc-windows-msvc' :
            arch === 'arm64' ? 'aarch64-pc-windows-msvc' :
            'i686-pc-windows-msvc';
    case 'linux':
        return arch === 'x64' ? 'x86_64-unknown-linux-musl' :
            arch === 'arm' ? 'arm-unknown-linux-gnueabihf' :
            arch === 'armv7l' ? 'arm-unknown-linux-gnueabihf' :
            arch === 'arm64' ? 'aarch64-unknown-linux-musl':
            arch === 'ppc64' ? 'powerpc64le-unknown-linux-gnu' :
            arch === 's390x' ? 's390x-unknown-linux-gnu' :
                'i686-unknown-linux-musl'
    default: throw new Error('Unknown platform: ' + platform);
}

}

Dominant language
JavaScript
Stars
203
Forks
66
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/vscode-ripgrep

All issues in microsoft/vscode-ripgrep

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.