chjj / charged

High-level Chargify API binding for node.js
MIT License
10 stars 5 forks source link

resolve paths #5

Open TimNZ opened 10 years ago

TimNZ commented 10 years ago

using the REPL shell and all ls commands fail.

Done some debugging and see that when attempting a 'ls' the following line ends up with an incorrect path on Windows, I expect you only tested on *nix based system.

bin\charged: 74

path = resolve('/', shell.cwd, path);

Resolves to 'c:\', subsequent request attempts then fail

TimNZ commented 10 years ago

I won't do a pull request as you may want to do something different but I add this to top of bin/charged:

var util = require('util')
  , readline = require('readline')
  , resolve_ = require('path').resolve
  , spawn = require('child_process').spawn
  , fs = require('fs')
  , isatty = require('tty').isatty
    , os = require('os')
  , charged = require('../');

function resolve()
{
    if (os.platform() != 'win32')
        return resolve_.apply(resolve_, arguments);

    var a = resolve_.apply(resolve_, arguments);
    var r = /^[A-Za-z]:(.*)$/;
    var m = a.match(r);
    return m[1].replace('\\','/');
}