ExtendScript api compatible with node.js.
ExtendScript has no setTimeout, so all functions are synchronous.
Main difference between func and funcSync is that funcSync
throw exeption, when error occures.
Anyway if you decide to use func insteed of funcSync do not use at as
synchronous, when setTimeout would be added to ExtendScript it would be
added to func to improve responsiveness of jsx scripts.
Described modules could be loaded with es-require as well.
var fs = require('lib/fs');Use #include lib/fs.js to use this module. The following methods are provided:
Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. mode defaults to 0777.
Synchronous fs.mkdir.
Asynchronous rename. No arguments other than a possible exception are given to the completion callback.
Synchronous fs.rename.
Writes data to a file.
fs.writeFile('hello.html', '<html></html>', function(error) {
if (error)
alert(error);
});Synchronous version of fs.writeFile.
try {
fs.writeFileSync('hello.html', '<html></html>');
} catch(error) {
alert(error);
}Reads data from a file.
fs.readFile('hello.html', function(error, data) {
if (error)
alert(error);
else
alert(data);
});Synchronous version of fs.readFile.
try {
var data = fs.readFileSync('hello.html');
alert(data);
} catch(error) {
alert(error);
}Use #include lib/path.js to use this module. The following methods are provided:
Return the directory name of a path. Similar to the Unix dirname command.
path.dirname('/foo/bar/baz/asdf/quux')
// returns
'/foo/bar/baz/asdf'Return the last portion of a path. Similar to the Unix basename command.
Example:
path.basename('/foo/bar/baz/asdf/quux.html')
// returns
'quux.html'
path.basename('/foo/bar/baz/asdf/quux.html', '.html')
// returns
'quux'Normalize a string path, taking care of '..', '.' and '~' parts.
var name = path.normalize('~/tmp/index.html');
// returns
'/Users/username/tmp/index.html'MIT