Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cash-global doesn't work in non-English operating systems #74

Open
loilo opened this issue Mar 16, 2016 · 2 comments
Open

cash-global doesn't work in non-English operating systems #74

loilo opened this issue Mar 16, 2016 · 2 comments

Comments

@loilo
Copy link

loilo commented Mar 16, 2016

Installing cash-global won't work properly in any OS whose language isn't English. That seems to be because of the test for the "Could not find" output of the where command in the bin/preinstall.js returning false positives in other languages.
I couldn't find it in the original source code though but I certainly don't actually have a grasp of the projects bigger structure.

For example the failing output of where in my German Windows looks like this

INFORMATION: Es konnten keine Dateien mit dem angegebenen Muster gefunden werden.

I'd suggest using the npm which package instead since it's going to be included in the application anyways according to #71.

@dthree
Copy link
Owner

dthree commented Mar 16, 2016

Okay thanks. Will check out!

@ghost
Copy link

ghost commented Jul 27, 2022

If you are under npm v6.x series or lower, the build command will be executed and you can install globally.
https://www.npmjs.com/package/cashx
You can use nodistx for nodejs version control.
https://github.com/wafflook/nodistx

install/preinstall.js

'use strict';

var fs = require('fs');
var os = require('os');
var path = require('path');
var execSync = require('child_process').execSync;

var commands = require(__dirname + path.sep + '..' + path.sep + 'commands.json');
var mute = require('./mute');

var pth = '.' + path.sep + 'package.json';
var file = fs.readFileSync(pth, 'utf8');
var json = JSON.parse(file);
json.bin = json.bin || {};

// Shut the fuck up.
mute();

// These commands shouldn't be installed
// globally on Windows.
var exclusions = commands.globalExclusions;

var stdout = '';
for (var i = 0; i < commands.commands.length; ++i) {
    var command = commands.commands[i];
    var excluded = (exclusions.indexOf(command) > -1);
    if (os.platform().indexOf('win') > -1 && !excluded) {
      try {
        execSync(`where ${command}`, {stdio: []});
        stdout += 'Command exists: ' + command + '\n';
      } catch (e) {
        json.bin[command] = './bin/' + command + '.js';
        stdout += 'Installed:      ' + command + '\n';
      }
    }
}

// Write the updated json.
fs.writeFileSync(pth, JSON.stringify(json, null, '  '));

// Remove the muzzle and print my 
// version of the stdout.
mute.unmute();
console.log(stdout);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants