I want to be able to run some command right before I start working with the code. It would run compiler, file watcher and live-reload (JS web project). The command is lengthy and due to Windows/Linux differences I need to store it in a text file in both forms (Windows uses different slashes for directories).
I know there’s Haxelib, but I couldn’t find any similar “scripts”: {} thing in the haxelib json file documentation.
Do you guys know what would help me? I’m considering using npm just for scripts but I’l like to avoid that if there’s Haxe alternative for it.
You would be able to add -cmd to your HXML file, but that occurs after your build, not before.
If you would like to have a watcher and live-reload for a JS project, using NPM might be the best approach, because there are many tools available for that task.
If you haven’t seen it already, you might check out the OpenFL samples for NPM:
You can remove the haxe “devDependency” to use a global Haxe install, or keep it in to work with a local copy.
Otherwise, I think it turns into one of a couple options:
1.) Add another dependency (such as NPM) to help with managing scripts
2.) Write bash files for Linux and macOS, and batch files for Windows
3.) Write and compile a Neko script for use on both
If you use Neko, it would look like this:
MyScript.hx
class MyScript {
public static function main () {
var args = Sys.args ();
Sys.command ("echo Hello World");
}
}
For now I’ve chosen just running Haxe files without compilation/outputting executable files. I will have couple of files in “tasks” directory, just to keep it tidy. In my case, I already have fast-live-reload (installed globally with npm), so now I’m just running:
haxe --run tasks.TestPage --debug
(which I can configure to be run on hitting key combination in my IDE)