Merge pull request #1444 from arturadib/new-bot
New files for Windows bot
This commit is contained in:
commit
6ec62cd148
22
external/shelljs/ChangeLog
vendored
Normal file
22
external/shelljs/ChangeLog
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
2012.03.22, Version 0.0.4
|
||||||
|
|
||||||
|
* ls() and find() return arrays instead of hashes (Artur Adib)
|
||||||
|
* exec({silent:...}) overrides global silent() state (Artur Adib)
|
||||||
|
|
||||||
|
|
||||||
|
2012.03.21, Version 0.0.3
|
||||||
|
|
||||||
|
* Wildcard bug fix (Artur Adib)
|
||||||
|
* execSync() now uses dummy file I/O op to reduce CPU usage (Artur Adib)
|
||||||
|
* Minor fixes
|
||||||
|
|
||||||
|
|
||||||
|
2012.03.15, Version 0.0.2
|
||||||
|
|
||||||
|
* New methods: find(), test() (Artur Adib)
|
||||||
|
* Deprecated non-Unix methods: exists(), verbose()
|
||||||
|
|
||||||
|
|
||||||
|
2012.03.03, Version 0.0.2pre1
|
||||||
|
|
||||||
|
* First public release
|
66
external/shelljs/README.md
vendored
66
external/shelljs/README.md
vendored
@ -1,6 +1,7 @@
|
|||||||
# ShellJS - Unix shell commands for Node.js [](http://travis-ci.org/arturadib/shelljs)
|
# ShellJS - Unix shell commands for Node.js [](http://travis-ci.org/arturadib/shelljs)
|
||||||
|
|
||||||
_This project is young and experimental. Use at your own risk._
|
+ _This project is young and experimental. Use at your own risk._
|
||||||
|
+ _Major API change as of v0.0.4: `ls()` and `find()` now return arrays._
|
||||||
|
|
||||||
ShellJS is a **portable** (Windows included) implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script's dependency on Unix while still keeping its familiar and powerful commands.
|
ShellJS is a **portable** (Windows included) implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script's dependency on Unix while still keeping its familiar and powerful commands.
|
||||||
|
|
||||||
@ -18,11 +19,11 @@ cp('-R', 'stuff/*', 'out/Release');
|
|||||||
|
|
||||||
// Replace macros in each .js file
|
// Replace macros in each .js file
|
||||||
cd('lib');
|
cd('lib');
|
||||||
for (file in ls('*.js')) {
|
ls('*.js').forEach(function(file) {
|
||||||
sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
|
sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
|
||||||
sed('-i', /.*REMOVE_THIS_LINE.*\n/, '', file);
|
sed('-i', /.*REMOVE_THIS_LINE.*\n/, '', file);
|
||||||
sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat('macro.js'), file);
|
sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat('macro.js'), file);
|
||||||
}
|
});
|
||||||
cd('..');
|
cd('..');
|
||||||
|
|
||||||
// Run external tool synchronously
|
// Run external tool synchronously
|
||||||
@ -73,11 +74,11 @@ target.docs = function() {
|
|||||||
cd(__dirname);
|
cd(__dirname);
|
||||||
mkdir('docs');
|
mkdir('docs');
|
||||||
cd('lib');
|
cd('lib');
|
||||||
for (file in ls('*.js')) {
|
ls('*.js').forEach(function(file){
|
||||||
var text = grep('//@', file); // extract special comments
|
var text = grep('//@', file); // extract special comments
|
||||||
text.replace('//@', ''); // remove comment tags
|
text.replace('//@', ''); // remove comment tags
|
||||||
text.to('docs/my_docs.md');
|
text.to('docs/my_docs.md');
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -128,9 +129,7 @@ ls('-R', '/users/me', '/tmp');
|
|||||||
ls('-R', ['/users/me', '/tmp']); // same as above
|
ls('-R', ['/users/me', '/tmp']); // same as above
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns list of files in the given path, or in current directory if no path provided.
|
Returns array of files in the given path, or in current directory if no path provided.
|
||||||
For convenient iteration via `for (file in ls())`, the format returned is a hash object:
|
|
||||||
`{ 'file1':null, 'dir1/file2':null, ...}`.
|
|
||||||
|
|
||||||
#### find(path [,path ...])
|
#### find(path [,path ...])
|
||||||
#### find(path_array)
|
#### find(path_array)
|
||||||
@ -139,18 +138,12 @@ Examples:
|
|||||||
```javascript
|
```javascript
|
||||||
find('src', 'lib');
|
find('src', 'lib');
|
||||||
find(['src', 'lib']); // same as above
|
find(['src', 'lib']); // same as above
|
||||||
for (file in find('.')) {
|
find('.').filter(function(file) { return file.match(/\.js$/); });
|
||||||
if (!file.match(/\.js$/))
|
|
||||||
continue;
|
|
||||||
// all files at this point end in '.js'
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns list of all files (however deep) in the given paths. For convenient iteration
|
Returns array of all files (however deep) in the given paths.
|
||||||
via `for (file in find(...))`, the format returned is a hash object:
|
|
||||||
`{ 'file1':null, 'dir1/file2':null, ...}`.
|
|
||||||
|
|
||||||
The main difference with respect to `ls('-R', path)` is that the resulting file names
|
The main difference from `ls('-R', path)` is that the resulting file names
|
||||||
include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
|
include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
|
||||||
|
|
||||||
#### cp('[options ,] source [,source ...], dest')
|
#### cp('[options ,] source [,source ...], dest')
|
||||||
@ -332,6 +325,10 @@ When in synchronous mode returns the object `{ code:..., output:... }`, containi
|
|||||||
`output` (stdout + stderr) and its exit `code`. Otherwise the `callback` gets the
|
`output` (stdout + stderr) and its exit `code`. Otherwise the `callback` gets the
|
||||||
arguments `(code, output)`.
|
arguments `(code, output)`.
|
||||||
|
|
||||||
|
**Note:** For long-lived processes, it's best to run `exec()` asynchronously as
|
||||||
|
the current synchronous implementation uses a lot of CPU. This should be getting
|
||||||
|
fixed soon.
|
||||||
|
|
||||||
## Non-Unix commands
|
## Non-Unix commands
|
||||||
|
|
||||||
|
|
||||||
@ -339,16 +336,35 @@ arguments `(code, output)`.
|
|||||||
Searches and returns string containing a writeable, platform-dependent temporary directory.
|
Searches and returns string containing a writeable, platform-dependent temporary directory.
|
||||||
Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
|
Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
|
||||||
|
|
||||||
#### exists(path [, path ...])
|
|
||||||
#### exists(path_array)
|
|
||||||
Returns true if all the given paths exist.
|
|
||||||
|
|
||||||
#### error()
|
#### error()
|
||||||
Tests if error occurred in the last command. Returns `null` if no error occurred,
|
Tests if error occurred in the last command. Returns `null` if no error occurred,
|
||||||
otherwise returns string explaining the error
|
otherwise returns string explaining the error
|
||||||
|
|
||||||
#### verbose()
|
#### silent([state])
|
||||||
Enables all output (default)
|
Example:
|
||||||
|
|
||||||
#### silent()
|
```javascript
|
||||||
Suppresses all output, except for explict `echo()` calls
|
var silentState = silent();
|
||||||
|
silent(true);
|
||||||
|
/* ... */
|
||||||
|
silent(silentState); // restore old silent state
|
||||||
|
```
|
||||||
|
|
||||||
|
Suppresses all command output if `state = true`, except for `echo()` calls.
|
||||||
|
Returns state if no arguments given.
|
||||||
|
|
||||||
|
## Deprecated
|
||||||
|
|
||||||
|
|
||||||
|
#### exists(path [, path ...])
|
||||||
|
#### exists(path_array)
|
||||||
|
|
||||||
|
_This function is being deprecated. Use `test()` instead._
|
||||||
|
|
||||||
|
Returns true if all the given paths exist.
|
||||||
|
|
||||||
|
#### verbose()
|
||||||
|
|
||||||
|
_This function is being deprecated. Use `silent(false) instead.`_
|
||||||
|
|
||||||
|
Enables all output (default)
|
||||||
|
2
external/shelljs/make.js
vendored
2
external/shelljs/make.js
vendored
@ -23,7 +23,7 @@ setTimeout(function() {
|
|||||||
if (oldTarget.done && !force)
|
if (oldTarget.done && !force)
|
||||||
return;
|
return;
|
||||||
oldTarget.done = true;
|
oldTarget.done = true;
|
||||||
return oldTarget(arguments);
|
return oldTarget.apply(oldTarget, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
})(t, target[t]);
|
})(t, target[t]);
|
||||||
|
35
external/shelljs/package.json
vendored
35
external/shelljs/package.json
vendored
@ -1,12 +1,29 @@
|
|||||||
{ "name": "shelljs"
|
{
|
||||||
, "version": "0.0.2pre1"
|
"name": "shelljs",
|
||||||
, "author": "Artur Adib <aadib@mozilla.com>"
|
"version": "0.0.5pre4",
|
||||||
, "description": "Portable Unix shell commands for Node.js"
|
"author": "Artur Adib <aadib@mozilla.com>",
|
||||||
, "keywords": ["unix", "shell", "makefile", "make", "jake", "synchronous"]
|
"description": "Portable Unix shell commands for Node.js",
|
||||||
, "repository": "git://github.com/arturadib/shelljs"
|
"keywords": [
|
||||||
, "homepage": "http://github.com/arturadib/shelljs"
|
"unix",
|
||||||
, "main": "./shell.js"
|
"shell",
|
||||||
, "scripts": {
|
"makefile",
|
||||||
|
"make",
|
||||||
|
"jake",
|
||||||
|
"synchronous"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/arturadib/shelljs.git"
|
||||||
|
},
|
||||||
|
"homepage": "http://github.com/arturadib/shelljs",
|
||||||
|
"main": "./shell.js",
|
||||||
|
"scripts": {
|
||||||
"test": "node scripts/run-tests"
|
"test": "node scripts/run-tests"
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {},
|
||||||
|
"optionalDependencies": {},
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
313
external/shelljs/shell.js
vendored
313
external/shelljs/shell.js
vendored
@ -74,9 +74,7 @@ exports.pwd = wrap('pwd', _pwd);
|
|||||||
//@ ls('-R', ['/users/me', '/tmp']); // same as above
|
//@ ls('-R', ['/users/me', '/tmp']); // same as above
|
||||||
//@ ```
|
//@ ```
|
||||||
//@
|
//@
|
||||||
//@ Returns list of files in the given path, or in current directory if no path provided.
|
//@ Returns array of files in the given path, or in current directory if no path provided.
|
||||||
//@ For convenient iteration via `for (file in ls())`, the format returned is a hash object:
|
|
||||||
//@ `{ 'file1':null, 'dir1/file2':null, ...}`.
|
|
||||||
function _ls(options, paths) {
|
function _ls(options, paths) {
|
||||||
options = parseOptions(options, {
|
options = parseOptions(options, {
|
||||||
'R': 'recursive',
|
'R': 'recursive',
|
||||||
@ -90,24 +88,30 @@ function _ls(options, paths) {
|
|||||||
else if (typeof paths === 'string')
|
else if (typeof paths === 'string')
|
||||||
paths = [].slice.call(arguments, 1);
|
paths = [].slice.call(arguments, 1);
|
||||||
|
|
||||||
var hash = {};
|
var list = [];
|
||||||
|
|
||||||
function pushHash(file, query) {
|
// Conditionally pushes file to list - returns true if pushed, false otherwise
|
||||||
|
// (e.g. prevents hidden files to be included unless explicitly told so)
|
||||||
|
function pushFile(file, query) {
|
||||||
// hidden file?
|
// hidden file?
|
||||||
if (path.basename(file)[0] === '.') {
|
if (path.basename(file)[0] === '.') {
|
||||||
// not explicitly asking for hidden files?
|
// not explicitly asking for hidden files?
|
||||||
if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1))
|
if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1))
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash[file] = null;
|
if (platform === 'win')
|
||||||
|
file = file.replace(/\\/g, '/');
|
||||||
|
|
||||||
|
list.push(file);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
paths.forEach(function(p) {
|
paths.forEach(function(p) {
|
||||||
if (fs.existsSync(p)) {
|
if (fs.existsSync(p)) {
|
||||||
// Simple file?
|
// Simple file?
|
||||||
if (fs.statSync(p).isFile()) {
|
if (fs.statSync(p).isFile()) {
|
||||||
pushHash(p, p);
|
pushFile(p, p);
|
||||||
return; // continue
|
return; // continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,14 +119,17 @@ function _ls(options, paths) {
|
|||||||
if (fs.statSync(p).isDirectory()) {
|
if (fs.statSync(p).isDirectory()) {
|
||||||
// Iterate over p contents
|
// Iterate over p contents
|
||||||
fs.readdirSync(p).forEach(function(file) {
|
fs.readdirSync(p).forEach(function(file) {
|
||||||
pushHash(file, p);
|
if (!pushFile(file, p))
|
||||||
|
return;
|
||||||
|
|
||||||
// Recursive
|
// Recursive?
|
||||||
var oldDir = _pwd();
|
if (options.recursive) {
|
||||||
_cd('', p);
|
var oldDir = _pwd();
|
||||||
if (fs.statSync(file).isDirectory() && options.recursive)
|
_cd('', p);
|
||||||
hash = extend(hash, _ls('-R', file+'/*'));
|
if (fs.statSync(file).isDirectory())
|
||||||
_cd('', oldDir);
|
list = list.concat(_ls('-R'+(options.all?'a':''), file+'/*'));
|
||||||
|
_cd('', oldDir);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return; // continue
|
return; // continue
|
||||||
}
|
}
|
||||||
@ -137,17 +144,20 @@ function _ls(options, paths) {
|
|||||||
// Escape special regular expression chars
|
// Escape special regular expression chars
|
||||||
var regexp = basename.replace(/(\^|\$|\(|\)|\<|\>|\[|\]|\{|\}|\.|\+|\?)/g, '\\$1');
|
var regexp = basename.replace(/(\^|\$|\(|\)|\<|\>|\[|\]|\{|\}|\.|\+|\?)/g, '\\$1');
|
||||||
// Translates wildcard into regex
|
// Translates wildcard into regex
|
||||||
regexp = '^' + regexp.replace(/\*/g, '.*');
|
regexp = '^' + regexp.replace(/\*/g, '.*') + '$';
|
||||||
// Iterate over directory contents
|
// Iterate over directory contents
|
||||||
fs.readdirSync(dirname).forEach(function(file) {
|
fs.readdirSync(dirname).forEach(function(file) {
|
||||||
if (file.match(new RegExp(regexp))) {
|
if (file.match(new RegExp(regexp))) {
|
||||||
pushHash(path.normalize(dirname+'/'+file), basename);
|
if (!pushFile(path.normalize(dirname+'/'+file), basename))
|
||||||
|
return;
|
||||||
|
|
||||||
// Recursive
|
// Recursive?
|
||||||
var pp = dirname + '/' + file;
|
if (options.recursive) {
|
||||||
if (fs.statSync(pp).isDirectory() && options.recursive)
|
var pp = dirname + '/' + file;
|
||||||
hash = extend(hash, _ls('-R', pp+'/*'));
|
if (fs.statSync(pp).isDirectory())
|
||||||
}
|
list = list.concat(_ls('-R'+(options.all?'a':''), pp+'/*'));
|
||||||
|
} // recursive
|
||||||
|
} // if file matches
|
||||||
}); // forEach
|
}); // forEach
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -155,7 +165,7 @@ function _ls(options, paths) {
|
|||||||
error('no such file or directory: ' + p, true);
|
error('no such file or directory: ' + p, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
return hash;
|
return list;
|
||||||
};
|
};
|
||||||
exports.ls = wrap('ls', _ls);
|
exports.ls = wrap('ls', _ls);
|
||||||
|
|
||||||
@ -168,16 +178,10 @@ exports.ls = wrap('ls', _ls);
|
|||||||
//@ ```javascript
|
//@ ```javascript
|
||||||
//@ find('src', 'lib');
|
//@ find('src', 'lib');
|
||||||
//@ find(['src', 'lib']); // same as above
|
//@ find(['src', 'lib']); // same as above
|
||||||
//@ for (file in find('.')) {
|
//@ find('.').filter(function(file) { return file.match(/\.js$/); });
|
||||||
//@ if (!file.match(/\.js$/))
|
|
||||||
//@ continue;
|
|
||||||
//@ // all files at this point end in '.js'
|
|
||||||
//@ }
|
|
||||||
//@ ```
|
//@ ```
|
||||||
//@
|
//@
|
||||||
//@ Returns list of all files (however deep) in the given paths. For convenient iteration
|
//@ Returns array of all files (however deep) in the given paths.
|
||||||
//@ via `for (file in find(...))`, the format returned is a hash object:
|
|
||||||
//@ `{ 'file1':null, 'dir1/file2':null, ...}`.
|
|
||||||
//@
|
//@
|
||||||
//@ The main difference from `ls('-R', path)` is that the resulting file names
|
//@ The main difference from `ls('-R', path)` is that the resulting file names
|
||||||
//@ include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
|
//@ include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
|
||||||
@ -189,21 +193,28 @@ function _find(options, paths) {
|
|||||||
else if (typeof paths === 'string')
|
else if (typeof paths === 'string')
|
||||||
paths = [].slice.call(arguments, 1);
|
paths = [].slice.call(arguments, 1);
|
||||||
|
|
||||||
var hash = {};
|
var list = [];
|
||||||
|
|
||||||
|
function pushFile(file) {
|
||||||
|
if (platform === 'win')
|
||||||
|
file = file.replace(/\\/g, '/');
|
||||||
|
list.push(file);
|
||||||
|
}
|
||||||
|
|
||||||
// why not simply do ls('-R', paths)? because the output wouldn't give the base dirs
|
// why not simply do ls('-R', paths)? because the output wouldn't give the base dirs
|
||||||
// to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory
|
// to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory
|
||||||
|
|
||||||
paths.forEach(function(file){
|
paths.forEach(function(file) {
|
||||||
hash[file] = null;
|
pushFile(file);
|
||||||
|
|
||||||
if (fs.statSync(file).isDirectory()) {
|
if (fs.statSync(file).isDirectory()) {
|
||||||
for (subfile in _ls('-Ra', file+'/*'))
|
_ls('-Ra', file+'/*').forEach(function(subfile) {
|
||||||
hash[subfile] = null;
|
pushFile(subfile);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return hash;
|
return list;
|
||||||
}
|
}
|
||||||
exports.find = wrap('find', _find);
|
exports.find = wrap('find', _find);
|
||||||
|
|
||||||
@ -347,9 +358,20 @@ function _rm(options, files) {
|
|||||||
|
|
||||||
// Remove simple file
|
// Remove simple file
|
||||||
if (fs.statSync(file).isFile()) {
|
if (fs.statSync(file).isFile()) {
|
||||||
fs.unlinkSync(file);
|
|
||||||
|
// Do not check for file writing permissions
|
||||||
|
if (options.force) {
|
||||||
|
_unlinkSync(file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isWriteable(file))
|
||||||
|
_unlinkSync(file);
|
||||||
|
else
|
||||||
|
error('permission denied: '+file, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} // simple file
|
||||||
|
|
||||||
// Path is an existing directory, but no -r flag given
|
// Path is an existing directory, but no -r flag given
|
||||||
if (fs.statSync(file).isDirectory() && !options.recursive) {
|
if (fs.statSync(file).isDirectory() && !options.recursive) {
|
||||||
@ -359,7 +381,7 @@ function _rm(options, files) {
|
|||||||
|
|
||||||
// Recursively remove existing directory
|
// Recursively remove existing directory
|
||||||
if (fs.statSync(file).isDirectory() && options.recursive) {
|
if (fs.statSync(file).isDirectory() && options.recursive) {
|
||||||
rmdirSyncRecursive(file);
|
rmdirSyncRecursive(file, options.force);
|
||||||
}
|
}
|
||||||
}); // forEach(file)
|
}); // forEach(file)
|
||||||
}; // rm
|
}; // rm
|
||||||
@ -582,7 +604,11 @@ function _to(options, file) {
|
|||||||
if (!fs.existsSync( path.dirname(file) ))
|
if (!fs.existsSync( path.dirname(file) ))
|
||||||
error('no such file or directory: ' + path.dirname(file));
|
error('no such file or directory: ' + path.dirname(file));
|
||||||
|
|
||||||
fs.writeFileSync(file, this.toString(), 'utf8');
|
try {
|
||||||
|
fs.writeFileSync(file, this.toString(), 'utf8');
|
||||||
|
} catch(e) {
|
||||||
|
error('could not write to file (code '+e.code+'): '+file, true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// In the future, when Proxies are default, we can add methods like `.to()` to primitive strings.
|
// In the future, when Proxies are default, we can add methods like `.to()` to primitive strings.
|
||||||
// For now, this is a dummy function to bookmark places we need such strings
|
// For now, this is a dummy function to bookmark places we need such strings
|
||||||
@ -751,7 +777,7 @@ exports.which = wrap('which', _which);
|
|||||||
//@ like `.to()`.
|
//@ like `.to()`.
|
||||||
function _echo(options) {
|
function _echo(options) {
|
||||||
var messages = [].slice.call(arguments, 1);
|
var messages = [].slice.call(arguments, 1);
|
||||||
log.apply(this, messages);
|
console.log.apply(this, messages);
|
||||||
return ShellString(messages.join(' '));
|
return ShellString(messages.join(' '));
|
||||||
};
|
};
|
||||||
exports.echo = wrap('echo', _echo);
|
exports.echo = wrap('echo', _echo);
|
||||||
@ -783,6 +809,10 @@ exports.env = process.env;
|
|||||||
//@ When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's
|
//@ When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's
|
||||||
//@ `output` (stdout + stderr) and its exit `code`. Otherwise the `callback` gets the
|
//@ `output` (stdout + stderr) and its exit `code`. Otherwise the `callback` gets the
|
||||||
//@ arguments `(code, output)`.
|
//@ arguments `(code, output)`.
|
||||||
|
//@
|
||||||
|
//@ **Note:** For long-lived processes, it's best to run `exec()` asynchronously as
|
||||||
|
//@ the current synchronous implementation uses a lot of CPU. This should be getting
|
||||||
|
//@ fixed soon.
|
||||||
function _exec(command, options, callback) {
|
function _exec(command, options, callback) {
|
||||||
if (!command)
|
if (!command)
|
||||||
error('must specify command');
|
error('must specify command');
|
||||||
@ -793,7 +823,7 @@ function _exec(command, options, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options = extend({
|
options = extend({
|
||||||
silent: false,
|
silent: state.silent,
|
||||||
async: false
|
async: false
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
@ -822,11 +852,53 @@ exports.exec = wrap('exec', _exec, {notUnix:true});
|
|||||||
//@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
|
//@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
|
||||||
exports.tempdir = wrap('tempdir', tempDir);
|
exports.tempdir = wrap('tempdir', tempDir);
|
||||||
|
|
||||||
|
|
||||||
|
//@
|
||||||
|
//@ #### error()
|
||||||
|
//@ Tests if error occurred in the last command. Returns `null` if no error occurred,
|
||||||
|
//@ otherwise returns string explaining the error
|
||||||
|
exports.error = function() {
|
||||||
|
return state.error;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@
|
||||||
|
//@ #### silent([state])
|
||||||
|
//@ Example:
|
||||||
|
//@
|
||||||
|
//@ ```javascript
|
||||||
|
//@ var silentState = silent();
|
||||||
|
//@ silent(true);
|
||||||
|
//@ /* ... */
|
||||||
|
//@ silent(silentState); // restore old silent state
|
||||||
|
//@ ```
|
||||||
|
//@
|
||||||
|
//@ Suppresses all command output if `state = true`, except for `echo()` calls.
|
||||||
|
//@ Returns state if no arguments given.
|
||||||
|
exports.silent = function(_state) {
|
||||||
|
if (typeof _state !== 'boolean')
|
||||||
|
return state.silent;
|
||||||
|
|
||||||
|
state.silent = _state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//@
|
||||||
|
//@ ## Deprecated
|
||||||
|
//@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//@
|
//@
|
||||||
//@ #### exists(path [, path ...])
|
//@ #### exists(path [, path ...])
|
||||||
//@ #### exists(path_array)
|
//@ #### exists(path_array)
|
||||||
|
//@
|
||||||
|
//@ _This function is being deprecated. Use `test()` instead._
|
||||||
|
//@
|
||||||
//@ Returns true if all the given paths exist.
|
//@ Returns true if all the given paths exist.
|
||||||
function _exists(options, paths) {
|
function _exists(options, paths) {
|
||||||
|
deprecate('exists', 'Use test() instead.');
|
||||||
|
|
||||||
if (!paths)
|
if (!paths)
|
||||||
error('no paths given');
|
error('no paths given');
|
||||||
|
|
||||||
@ -844,32 +916,19 @@ function _exists(options, paths) {
|
|||||||
};
|
};
|
||||||
exports.exists = wrap('exists', _exists);
|
exports.exists = wrap('exists', _exists);
|
||||||
|
|
||||||
//@
|
|
||||||
//@ #### error()
|
|
||||||
//@ Tests if error occurred in the last command. Returns `null` if no error occurred,
|
|
||||||
//@ otherwise returns string explaining the error
|
|
||||||
exports.error = function() {
|
|
||||||
return state.error;
|
|
||||||
}
|
|
||||||
|
|
||||||
//@
|
//@
|
||||||
//@ #### verbose()
|
//@ #### verbose()
|
||||||
|
//@
|
||||||
|
//@ _This function is being deprecated. Use `silent(false) instead.`_
|
||||||
|
//@
|
||||||
//@ Enables all output (default)
|
//@ Enables all output (default)
|
||||||
exports.verbose = function() {
|
exports.verbose = function() {
|
||||||
|
deprecate('verbose', 'Use silent(false) instead.');
|
||||||
|
|
||||||
state.silent = false;
|
state.silent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@
|
|
||||||
//@ #### silent()
|
|
||||||
//@ Suppresses all output, except for explict `echo()` calls
|
|
||||||
exports.silent = function() {
|
|
||||||
state.silent = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -889,6 +948,10 @@ function log() {
|
|||||||
console.log.apply(this, arguments);
|
console.log.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deprecate(what, msg) {
|
||||||
|
console.log('*** ShellJS.'+what+': This function is deprecated.', msg);
|
||||||
|
}
|
||||||
|
|
||||||
function write(msg) {
|
function write(msg) {
|
||||||
if (!state.silent)
|
if (!state.silent)
|
||||||
process.stdout.write(msg);
|
process.stdout.write(msg);
|
||||||
@ -962,7 +1025,7 @@ function wrap(cmd, fn, options) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!state.error) {
|
if (!state.error) {
|
||||||
// If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
|
// If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
|
||||||
console.log('maker.js: internal error');
|
console.log('shell.js: internal error');
|
||||||
console.log(e.stack || e);
|
console.log(e.stack || e);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@ -970,7 +1033,7 @@ function wrap(cmd, fn, options) {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.currentCmd = 'maker.js';
|
state.currentCmd = 'shell.js';
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
} // wrap
|
} // wrap
|
||||||
@ -984,10 +1047,22 @@ function copyFileSync(srcFile, destFile) {
|
|||||||
|
|
||||||
var BUF_LENGTH = 64*1024,
|
var BUF_LENGTH = 64*1024,
|
||||||
buf = new Buffer(BUF_LENGTH),
|
buf = new Buffer(BUF_LENGTH),
|
||||||
fdr = fs.openSync(srcFile, 'r'),
|
|
||||||
fdw = fs.openSync(destFile, 'w'),
|
|
||||||
bytesRead = BUF_LENGTH,
|
bytesRead = BUF_LENGTH,
|
||||||
pos = 0;
|
pos = 0,
|
||||||
|
fdr = null,
|
||||||
|
fdw = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
fdr = fs.openSync(srcFile, 'r');
|
||||||
|
} catch(e) {
|
||||||
|
error('copyFileSync: could not read src file ('+srcFile+')');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fdw = fs.openSync(destFile, 'w');
|
||||||
|
} catch(e) {
|
||||||
|
error('copyFileSync: could not write to dest file (code='+e.code+'):'+destFile);
|
||||||
|
}
|
||||||
|
|
||||||
while (bytesRead === BUF_LENGTH) {
|
while (bytesRead === BUF_LENGTH) {
|
||||||
bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
|
bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
|
||||||
@ -1050,28 +1125,41 @@ function cpdirSyncRecursive(sourceDir, destDir, opts) {
|
|||||||
//
|
//
|
||||||
// Licensed under the MIT License
|
// Licensed under the MIT License
|
||||||
// http://www.opensource.org/licenses/mit-license.php
|
// http://www.opensource.org/licenses/mit-license.php
|
||||||
function rmdirSyncRecursive(dir) {
|
function rmdirSyncRecursive(dir, force) {
|
||||||
var files;
|
var files;
|
||||||
|
|
||||||
files = fs.readdirSync(dir);
|
files = fs.readdirSync(dir);
|
||||||
|
|
||||||
// Loop through and delete everything in the sub-tree after checking it
|
// Loop through and delete everything in the sub-tree after checking it
|
||||||
for(var i = 0; i < files.length; i++) {
|
for(var i = 0; i < files.length; i++) {
|
||||||
var currFile = fs.lstatSync(dir + "/" + files[i]);
|
var file = dir + "/" + files[i],
|
||||||
|
currFile = fs.lstatSync(file);
|
||||||
|
|
||||||
if(currFile.isDirectory()) // Recursive function back to the beginning
|
if(currFile.isDirectory()) { // Recursive function back to the beginning
|
||||||
rmdirSyncRecursive(dir + "/" + files[i]);
|
rmdirSyncRecursive(file, force);
|
||||||
|
}
|
||||||
|
|
||||||
else if(currFile.isSymbolicLink()) // Unlink symlinks
|
else if(currFile.isSymbolicLink()) { // Unlink symlinks
|
||||||
fs.unlinkSync(dir + "/" + files[i]);
|
if (force || isWriteable(file))
|
||||||
|
_unlinkSync(file);
|
||||||
|
}
|
||||||
|
|
||||||
else // Assume it's a file - perhaps a try/catch belongs here?
|
else // Assume it's a file - perhaps a try/catch belongs here?
|
||||||
fs.unlinkSync(dir + "/" + files[i]);
|
if (force || isWriteable(file))
|
||||||
|
_unlinkSync(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we know everything in the sub-tree has been deleted, we can delete the main directory.
|
// Now that we know everything in the sub-tree has been deleted, we can delete the main directory.
|
||||||
// Huzzah for the shopkeep.
|
// Huzzah for the shopkeep.
|
||||||
return fs.rmdirSync(dir);
|
|
||||||
|
var result;
|
||||||
|
try {
|
||||||
|
result = fs.rmdirSync(dir);
|
||||||
|
} catch(e) {
|
||||||
|
error('could not remove directory (code '+e.code+'): ' + dir, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}; // rmdirSyncRecursive
|
}; // rmdirSyncRecursive
|
||||||
|
|
||||||
// Recursively creates 'dir'
|
// Recursively creates 'dir'
|
||||||
@ -1118,7 +1206,7 @@ function writeableDir(dir) {
|
|||||||
var testFile = dir+'/'+randomFileName();
|
var testFile = dir+'/'+randomFileName();
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(testFile, ' ');
|
fs.writeFileSync(testFile, ' ');
|
||||||
fs.unlinkSync(testFile);
|
_unlinkSync(testFile);
|
||||||
return dir;
|
return dir;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
@ -1151,6 +1239,10 @@ function tempDir() {
|
|||||||
// Wrapper around exec() to enable echoing output to console in real time
|
// Wrapper around exec() to enable echoing output to console in real time
|
||||||
function execAsync(cmd, opts, callback) {
|
function execAsync(cmd, opts, callback) {
|
||||||
var output = '';
|
var output = '';
|
||||||
|
|
||||||
|
var options = extend({
|
||||||
|
silent: state.silent
|
||||||
|
}, opts);
|
||||||
|
|
||||||
var c = child.exec(cmd, {env: process.env}, function(err) {
|
var c = child.exec(cmd, {env: process.env}, function(err) {
|
||||||
if (callback)
|
if (callback)
|
||||||
@ -1159,14 +1251,14 @@ function execAsync(cmd, opts, callback) {
|
|||||||
|
|
||||||
c.stdout.on('data', function(data) {
|
c.stdout.on('data', function(data) {
|
||||||
output += data;
|
output += data;
|
||||||
if (!opts.silent)
|
if (!options.silent)
|
||||||
write(data);
|
process.stdout.write(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
c.stderr.on('data', function(data) {
|
c.stderr.on('data', function(data) {
|
||||||
output += data;
|
output += data;
|
||||||
if (!opts.silent)
|
if (!options.silent)
|
||||||
write(data);
|
process.stdout.write(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1178,16 +1270,17 @@ function execAsync(cmd, opts, callback) {
|
|||||||
function execSync(cmd, opts) {
|
function execSync(cmd, opts) {
|
||||||
var stdoutFile = path.resolve(tempDir()+'/'+randomFileName()),
|
var stdoutFile = path.resolve(tempDir()+'/'+randomFileName()),
|
||||||
codeFile = path.resolve(tempDir()+'/'+randomFileName()),
|
codeFile = path.resolve(tempDir()+'/'+randomFileName()),
|
||||||
scriptFile = path.resolve(tempDir()+'/'+randomFileName());
|
scriptFile = path.resolve(tempDir()+'/'+randomFileName()),
|
||||||
|
sleepFile = path.resolve(tempDir()+'/'+randomFileName());
|
||||||
|
|
||||||
var options = extend({
|
var options = extend({
|
||||||
silent: false
|
silent: state.silent
|
||||||
}, opts);
|
}, opts);
|
||||||
|
|
||||||
var previousStdoutContent = '';
|
var previousStdoutContent = '';
|
||||||
// Echoes stdout changes from running process, if not silent
|
// Echoes stdout changes from running process, if not silent
|
||||||
function updateStdout() {
|
function updateStdout() {
|
||||||
if (state.silent || options.silent || !fs.existsSync(stdoutFile))
|
if (options.silent || !fs.existsSync(stdoutFile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var stdoutContent = fs.readFileSync(stdoutFile, 'utf8');
|
var stdoutContent = fs.readFileSync(stdoutFile, 'utf8');
|
||||||
@ -1214,9 +1307,9 @@ function execSync(cmd, opts) {
|
|||||||
fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0'); \
|
fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0'); \
|
||||||
});";
|
});";
|
||||||
|
|
||||||
if (fs.existsSync(scriptFile)) fs.unlinkSync(scriptFile);
|
if (fs.existsSync(scriptFile)) _unlinkSync(scriptFile);
|
||||||
if (fs.existsSync(stdoutFile)) fs.unlinkSync(stdoutFile);
|
if (fs.existsSync(stdoutFile)) _unlinkSync(stdoutFile);
|
||||||
if (fs.existsSync(codeFile)) fs.unlinkSync(codeFile);
|
if (fs.existsSync(codeFile)) _unlinkSync(codeFile);
|
||||||
|
|
||||||
fs.writeFileSync(scriptFile, script);
|
fs.writeFileSync(scriptFile, script);
|
||||||
child.exec('node '+scriptFile, {
|
child.exec('node '+scriptFile, {
|
||||||
@ -1225,8 +1318,11 @@ function execSync(cmd, opts) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// The wait loop
|
// The wait loop
|
||||||
while (!fs.existsSync(codeFile)) { updateStdout(); };
|
// sleepFile is used as a dummy I/O op to mitigate unnecessary CPU usage
|
||||||
while (!fs.existsSync(stdoutFile)) { updateStdout(); };
|
// (tried many I/O sync ops, writeFileSync() seems to be only one that is effective in reducing
|
||||||
|
// CPU usage, though apparently not so much on Windows)
|
||||||
|
while (!fs.existsSync(codeFile)) { updateStdout(); fs.writeFileSync(sleepFile, 'a'); };
|
||||||
|
while (!fs.existsSync(stdoutFile)) { updateStdout(); fs.writeFileSync(sleepFile, 'a'); };
|
||||||
|
|
||||||
// At this point codeFile exists, but it's not necessarily flushed yet.
|
// At this point codeFile exists, but it's not necessarily flushed yet.
|
||||||
// Keep reading it until it is.
|
// Keep reading it until it is.
|
||||||
@ -1236,10 +1332,12 @@ function execSync(cmd, opts) {
|
|||||||
|
|
||||||
var stdout = fs.readFileSync(stdoutFile, 'utf8');
|
var stdout = fs.readFileSync(stdoutFile, 'utf8');
|
||||||
|
|
||||||
fs.unlinkSync(scriptFile);
|
// No biggie if we can't erase the files now -- they're in a temp dir anyway
|
||||||
fs.unlinkSync(stdoutFile);
|
try { _unlinkSync(scriptFile); } catch(e) {};
|
||||||
fs.unlinkSync(codeFile);
|
try { _unlinkSync(stdoutFile); } catch(e) {};
|
||||||
|
try { _unlinkSync(codeFile); } catch(e) {};
|
||||||
|
try { _unlinkSync(sleepFile); } catch(e) {};
|
||||||
|
|
||||||
// True if successful, false if not
|
// True if successful, false if not
|
||||||
var obj = {
|
var obj = {
|
||||||
code: code,
|
code: code,
|
||||||
@ -1257,8 +1355,9 @@ function expand(list) {
|
|||||||
list.forEach(function(listEl) {
|
list.forEach(function(listEl) {
|
||||||
// Wildcard present?
|
// Wildcard present?
|
||||||
if (listEl.search(/\*/) > -1) {
|
if (listEl.search(/\*/) > -1) {
|
||||||
for (file in _ls('', listEl))
|
_ls('', listEl).forEach(function(file) {
|
||||||
expanded.push(file);
|
expanded.push(file);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
expanded.push(listEl);
|
expanded.push(listEl);
|
||||||
}
|
}
|
||||||
@ -1290,3 +1389,33 @@ function extend(target) {
|
|||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Normalizes _unlinkSync() across platforms to match Unix behavior, i.e.
|
||||||
|
// file can be unlinked even if it's read-only, see joyent/node#3006
|
||||||
|
function _unlinkSync(file) {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(file);
|
||||||
|
} catch(e) {
|
||||||
|
// Try to override file permission
|
||||||
|
if (e.code === 'EPERM') {
|
||||||
|
fs.chmodSync(file, '0666');
|
||||||
|
fs.unlinkSync(file);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hack to determine if file has write permissions for current user
|
||||||
|
// Avoids having to check user, group, etc, but it's probably slow
|
||||||
|
function isWriteable(file) {
|
||||||
|
var writePermission = true;
|
||||||
|
try {
|
||||||
|
var __fd = fs.openSync(file, 'a');
|
||||||
|
fs.closeSync(__fd);
|
||||||
|
} catch(e) {
|
||||||
|
writePermission = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return writePermission;
|
||||||
|
}
|
||||||
|
58
make.js
58
make.js
@ -100,7 +100,7 @@ target.bundle = function() {
|
|||||||
'bidi.js',
|
'bidi.js',
|
||||||
'metadata.js'];
|
'metadata.js'];
|
||||||
|
|
||||||
if (!exists(BUILD_DIR))
|
if (!test('-d', BUILD_DIR))
|
||||||
mkdir(BUILD_DIR);
|
mkdir(BUILD_DIR);
|
||||||
|
|
||||||
cd('src');
|
cd('src');
|
||||||
@ -143,10 +143,10 @@ target.pagesrepo = function() {
|
|||||||
echo();
|
echo();
|
||||||
echo('### Creating fresh clone of gh-pages');
|
echo('### Creating fresh clone of gh-pages');
|
||||||
|
|
||||||
if (!exists(BUILD_DIR))
|
if (!test('-d', BUILD_DIR))
|
||||||
mkdir(BUILD_DIR);
|
mkdir(BUILD_DIR);
|
||||||
|
|
||||||
if (!exists(GH_PAGES_DIR)) {
|
if (!test('-d', GH_PAGES_DIR)) {
|
||||||
echo();
|
echo();
|
||||||
echo('Cloning project repo...');
|
echo('Cloning project repo...');
|
||||||
echo('(This operation can take a while, depending on network conditions)');
|
echo('(This operation can take a while, depending on network conditions)');
|
||||||
@ -278,10 +278,10 @@ target.firefox = function() {
|
|||||||
// We don't need pdf.js anymore since its inlined
|
// We don't need pdf.js anymore since its inlined
|
||||||
rm('-Rf', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
|
rm('-Rf', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
|
||||||
// Remove '.DS_Store' and other hidden files
|
// Remove '.DS_Store' and other hidden files
|
||||||
for (file in find(FIREFOX_BUILD_DIR)) {
|
find(FIREFOX_BUILD_DIR).forEach(function(file) {
|
||||||
if (file.match(/^\./))
|
if (file.match(/^\./))
|
||||||
rm('-f', file);
|
rm('-f', file);
|
||||||
}
|
});
|
||||||
|
|
||||||
// Update the build version number
|
// Update the build version number
|
||||||
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/install.rdf');
|
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/install.rdf');
|
||||||
@ -305,10 +305,10 @@ target.firefox = function() {
|
|||||||
// List all files for mozilla-central
|
// List all files for mozilla-central
|
||||||
cd(FIREFOX_BUILD_DIR);
|
cd(FIREFOX_BUILD_DIR);
|
||||||
var extensionFiles = '';
|
var extensionFiles = '';
|
||||||
for (file in find(FIREFOX_MC_EXTENSION_FILES)) {
|
find(FIREFOX_MC_EXTENSION_FILES).forEach(function(file){
|
||||||
if (test('-f', file))
|
if (test('-f', file))
|
||||||
extensionFiles += file+'\n';
|
extensionFiles += file+'\n';
|
||||||
}
|
});
|
||||||
extensionFiles.to('extension-files');
|
extensionFiles.to('extension-files');
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -361,10 +361,19 @@ target.test = function() {
|
|||||||
target.unittest();
|
target.unittest();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// make bottest
|
||||||
|
// (Special tests for the Github bot)
|
||||||
|
//
|
||||||
|
target.bottest = function() {
|
||||||
|
target.browsertest({noreftest: true});
|
||||||
|
// target.unittest();
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// make browsertest
|
// make browsertest
|
||||||
//
|
//
|
||||||
target.browsertest = function() {
|
target.browsertest = function(options) {
|
||||||
cd(ROOT_DIR);
|
cd(ROOT_DIR);
|
||||||
echo();
|
echo();
|
||||||
echo('### Running browser tests');
|
echo('### Running browser tests');
|
||||||
@ -372,14 +381,16 @@ target.browsertest = function() {
|
|||||||
var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
|
var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
|
||||||
PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
|
PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
|
||||||
|
|
||||||
if (!exists('test/' + PDF_BROWSERS)) {
|
if (!test('-f', 'test/' + PDF_BROWSERS)) {
|
||||||
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
|
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
|
||||||
echo('Try copying one of the examples in test/resources/browser_manifests/');
|
echo('Try copying one of the examples in test/resources/browser_manifests/');
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var reftest = (options && options.noreftest) ? '' : '--reftest';
|
||||||
|
|
||||||
cd('test');
|
cd('test');
|
||||||
exec(PYTHON_BIN + ' test.py --reftest --browserManifestFile=' + PDF_BROWSERS +
|
exec(PYTHON_BIN + ' -u test.py '+reftest+' --browserManifestFile=' + PDF_BROWSERS +
|
||||||
' --manifestFile=' + PDF_TEST, {async: true});
|
' --manifestFile=' + PDF_TEST, {async: true});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -391,10 +402,37 @@ target.unittest = function() {
|
|||||||
echo();
|
echo();
|
||||||
echo('### Running unit tests');
|
echo('### Running unit tests');
|
||||||
|
|
||||||
|
if (!which('make')) {
|
||||||
|
echo('make not found. Skipping unit tests...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cd('test/unit');
|
cd('test/unit');
|
||||||
exec('make', {async: true});
|
exec('make', {async: true});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// make botmakeref
|
||||||
|
//
|
||||||
|
target.botmakeref = function() {
|
||||||
|
cd(ROOT_DIR);
|
||||||
|
echo();
|
||||||
|
echo('### Creating reference images');
|
||||||
|
|
||||||
|
var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
|
||||||
|
PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
|
||||||
|
|
||||||
|
if (!test('-f', 'test/' + PDF_BROWSERS)) {
|
||||||
|
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
|
||||||
|
echo('Try copying one of the examples in test/resources/browser_manifests/');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
cd('test');
|
||||||
|
exec(PYTHON_BIN + ' -u test.py --masterMode --noPrompts --browserManifestFile=' + PDF_BROWSERS,
|
||||||
|
{async: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -1 +1 @@
|
|||||||
http://www.cdc.gov/ncidod/dvbid/westnile/languages/chinese.pdf
|
http://web.archive.org/web/20110623114753/http://www.cdc.gov/ncidod/dvbid/westnile/languages/chinese.pdf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user