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

Windows: can't pass a path from the command line when creating Durandal skeleton project #339

Closed
sennett opened this issue Jan 10, 2014 · 9 comments

Comments

@sennett
Copy link

sennett commented Jan 10, 2014

Running with path breaks:

C:\Users\Anthony>mimosa skel:new durandal "C:\Users\Anthony\node projects\typele
arn"
13:16:11 - Retrieving registry...
13:16:11 - Found skeleton in registry
13:16:11 - Cloning GitHub repo [[ git://github.com/BlueSpire/Durandal-Mimosa-Ske
leton.git ]] to temp holding directory.
13:16:13 - Moving cloned repo to  [[ C:\Users\Anthony\C:\Users\Anthony\node proj
ects\typelearn ]].

fs.js:642
  return binding.mkdir(pathModule._makeLong(path),
                 ^
Error: ENOENT, no such file or directory 'C:\Users\Anthony\C:\Users\Anthony\node
 projects\typelearn'
    at Object.fs.mkdirSync (fs.js:642:18)
    at _moveDirectoryContents (C:\Users\Anthony\AppData\Roaming\npm\node_modules
\mimosa\node_modules\skelmimosa\lib\command\new.js:87:8)
    at C:\Users\Anthony\AppData\Roaming\npm\node_modules\mimosa\node_modules\ske
lmimosa\lib\command\new.js:64:5
    at ChildProcess.exithandler (child_process.js:635:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

C:\Users\Anthony>

but doing so without the path is fine:

C:\Users\Anthony\node projects\typelearn>mimosa skel:new durandal
14:28:11 - Retrieving registry...
14:28:11 - Found skeleton in registry
14:28:11 - Cloning GitHub repo [[ git://github.com/BlueSpire/Durandal-Mimosa-Ske
leton.git ]] to temp holding directory.
14:28:13 - Moving cloned repo to  [[ C:\Users\Anthony\node projects\typelearn ]]
.
14:28:13 - Cleaning up...
14:28:13 - Skeleton successfully cloned from GitHub.

C:\Users\Anthony\node projects\typelearn>

I was recommended to use the path in the Durandal docs, so please forgive me if this is not the recommended way. I had a quick look at the Mimosa docs and couldn't see anything obvious.

SO question: http://stackoverflow.com/q/21053251/614523

@sennett
Copy link
Author

sennett commented Jan 10, 2014

As noted by Brandon Pugh (http://stackoverflow.com/a/21055014/614523) this bug may be that the command line does not accept absolute paths.

@Anachron
Copy link
Contributor

I believe the reason is here with concatenating the outPath var:
https://github.com/dbashford/mimosa/blob/master/lib/command/new.js#L54

A quick fix would be using a regex

if(/^\\(?!\\)/.test(path)){
    outPath = name; // path is absolute
}else{
    outPath = path.join(process.cwd(), name) // path is relative
}
this.skeletonOutPath = name ? (fs.existsSync(outPath) ? (logger.error("Directory/file exists at [[ " + outPath + " ]], cannot continue."), process.exit(0)) : void 0, outPath) : path.dirname(outPath);

It's not tested, but should work.
Notice that the last directory is changed from process.cwd() to path.dirname(outPath)

http://nodejs.org/api/process.html#process_process_cwd
http://nodejs.org/api/path.html#path_path_dirname_p

@dbashford
Copy link
Owner

This problem is in skelmimosa, not mimosa proper. Which doesn't mean that it necessarily wouldn't be an issue in mimosa new too.

https://github.com/dbashford/skelmimosa/blob/master/src/command/new.coffee#L25

I never meant you to be able to pass full paths, just essentially the name of the folder you'd like skel:new to create. But I can see how providing a full path would be nice. I'll play with it. I imagine this won't work on #nix either. At least not well.

@Anachron
Copy link
Contributor

Why not just check for "" or "/" in pathname and if so, it's supposed to be absolute?
But then again, you can do local stuff like "../../myproject".

@dbashford
Copy link
Owner

I've published what I believe to be a fix for this. Hard to say on windows since I cannot test that.

v1.3.9

@Anachron
Copy link
Contributor

Command:

PS D:\dev> mimosa new D:\dev\test
fs.js:642
  return binding.mkdir(pathModule._makeLong(path),
                 ^
Error: ENOENT, no such file or directory 'D:\dev\D:\dev\test'
    at Object.fs.mkdirSync (fs.js:642:18)
    at NewCommand._moveDirectoryContents (D:\apps\scoop\apps\nodejs\0.10.23\node
_modules\mimosa\lib\command\new.js:164:10)
    at NewCommand._create (D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mimosa
\lib\command\new.js:132:10)
    at NewCommand._create (D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mimosa
\lib\command\new.js:2:59)
    at D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mimosa\lib\command\new.js:
97:28
    at D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mimosa\node_modules\comman
der\index.js:1073:9
    at ReadStream.<anonymous> (D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mi
mosa\node_modules\commander\index.js:860:5)
    at ReadStream.g (events.js:180:16)
    at ReadStream.EventEmitter.emit (events.js:95:17)
    at ReadStream.<anonymous> (_stream_readable.js:746:14)
    at ReadStream.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at ReadStream.Readable.push (_stream_readable.js:127:10)
    at TTY.onread (net.js:526:21)
PS D:\dev> mimosa -V
1.3.9

Edit:
https://github.com/dbashford/mimosa/blob/master/src/command/new.coffee#L39

      outPath = path.join process.cwd(), name

Still wrong

@dbashford
Copy link
Owner

That's a similar though different issue. Could you copy paste that as a new issue? Away from my laptop.


On 2014-01-11 22:54:43 +0000 Anachron [email protected] wrote:

Command:
PS D:\dev> mimosa new D:\dev\test

fs.js:642
  return binding.mkdir(pathModule._makeLong(path),
                 ^
Error: ENOENT, no such file or directory 'D:\dev\D:\dev\test'
    at Object.fs.mkdirSync (fs.js:642:18)
    at NewCommand._moveDirectoryContents 
(D:\apps\scoop\apps\nodejs\0.10.23\node
_modules\mimosa\lib\command\new.js:164:10)
    at NewCommand._create 
(D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mimosa
\lib\command\new.js:132:10)
    at NewCommand._create 
(D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mimosa
\lib\command\new.js:2:59)
    at 
D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mimosa\lib\command\new.js:
97:28
    at 
D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mimosa\node_modules\comman
der\index.js:1073:9
    at ReadStream.<anonymous> 
(D:\apps\scoop\apps\nodejs\0.10.23\node_modules\mi
mosa\node_modules\commander\index.js:860:5)
    at ReadStream.g (events.js:180:16)
    at ReadStream.EventEmitter.emit (events.js:95:17)
    at ReadStream.<anonymous> (_stream_readable.js:746:14)
    at ReadStream.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at ReadStream.Readable.push (_stream_readable.js:127:10)
    at TTY.onread (net.js:526:21)
PS D:\dev> mimosa -V
1.3.9

Reply to this email directly or view it on GitHub:
#339 (comment)

@Anachron
Copy link
Contributor

Opened as new issue: #340

@dbashford
Copy link
Owner

Thanks much!


On 2014-01-11 23:07:34 +0000 Anachron [email protected] wrote:

Opened as new issue: #340


Reply to this email directly or view it on GitHub:
#339 (comment)

dbashford added a commit to dbashford/skelmimosa that referenced this issue Jan 22, 2014
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

3 participants