Skip to content

Instantly share code, notes, and snippets.

@Deltachaos
Created April 8, 2014 11:56
Show Gist options
  • Save Deltachaos/10114135 to your computer and use it in GitHub Desktop.
Save Deltachaos/10114135 to your computer and use it in GitHub Desktop.
nodejs implementation of sys package. Untyped vs typed using node externs
package sys;
import js.Node;
using StringTools;
#if !macro
/**
This class allows you to get informations about the files and directories.
**/
class FileSystem
{
/**
Tells if the given file or directory exists.
**/
inline public static function exists( path : String ) : Bool
{
return Node.fs.existsSync(path);
}
// [...]
}
#else
class FileSystem
{}
#end
package sys;
#if !macro
/**
This class allows you to get informations about the files and directories.
**/
class FileSystem
{
/**
Tells if the given file or directory exists.
**/
inline public static function exists( path : String ) : Bool
{
return untyped __js__("require('fs').existsSync(path)");
}
// [...]
}
#else
class FileSystem
{}
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment