Question

I'm trying to create some commands for my haxe library, but I have a problem. In fact, I want to generate some files and directories in the directory where the command haxelib run <mylib> <command> is send.

But, when it runs it generates the data in my lib directory (where the run.n is). My path is the following :

Sys.getCwd() + "/myfile.txt"

I also tried

"myfile.txt"

Always the same thing. Perhaps that's because I installed my library with haxelib git?

flixel-tools has a command that generates something too, but that's directly with flixel tpl -n 'name'. They don't use haxelib run flixel. That's why it works for them ?

Thank you if you have an idea.

Was it helpful?

Solution

From the Using haxelib wiki page:

When run.n is called from haxelib, the current working directory will be set to the library directory (eg. /usr/lib/haxe/lib/somelib/1,0/). The directory of haxelib being called will instead be passed as an extra argument, put at the end of the argument array.

Example usage:

var haxelibDir = Sys.getCwd();
var userDir = Sys.args().pop();
Sys.setCwd( userDir );

// Now copy a sample file from the haxelib dir to the user's current dir:
var content = File.getContent( '$haxelibDir/tpl/myfile.txt' );
File.saveContent( '$userDir/myfile.txt', content );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top