commit | e6d8130ebfcddfe67c969e494d92429bbca9c9af | [log] [tgz] |
---|---|---|
author | Oliver Salzburg <oliver.salzburg@gmail.com> | Tue Dec 18 22:47:14 2018 +0100 |
committer | エリス <erisu@users.noreply.github.com> | Wed Dec 19 06:47:14 2018 +0900 |
tree | 235eba16c079f6e02d297dbd53ed88fb4cf4cfe5 | |
parent | ce6559d45d15fa76d5d149160bc0feb26d7c2477 [diff] |
Don't restore mocked resource prior to resolution (#15) * Don't restore mocked resource prior to resolution The previous code had the possibility of restoring the mocked `open` module, actually shelling out and failing. * Ensure `open` is mocked in all cases Because the default behavior is to use the default browser (and invoke it with `open`) it needs to be properly mocked in all tests.
This module can be used to serve up a Cordova application in the browser. It has no command-line, but rather is intended to be called using the following API:
var cordovaServe = require('cordova-serve')(); cordovaServe.launchServer(opts); cordovaServe.servePlatform(platform, opts); cordovaServe.launchBrowser(ops);
var cordovaServe = require('cordova-serve')(); cordovaServe.launchServer(opts).then(function () { var server = cordovaServe.server; var root = cordovaServe.root; var port = cordovaServe.port; ... }, function (error) { console.log('An error occurred: ' + error); });
Launches a server with the specified options. Parameters:
Returns a promise that is fulfilled once the server has launched, or rejected if the server fails to launch. Once the promise is fulfilled, the following properties are available on the cordovaServe
object:
var cordovaServe = require('cordova-serve')(); cordovaServe.servePlatform(platform, opts).then(function () { var server = cordovaServe.server; var port = cordovaServe.port; var projectRoot = cordovaServe.projectRoot; var platformRoot = cordovaServe.root; ... }, function (error) { console.log('An error occurred: ' + error); });
Launches a server that serves up any Cordova platform (e.g. browser
, android
etc) from the current project. Parameters:
servePlatform()
, the root
value should be a Cordova project‘s root folder, or any folder within it - servePlatform()
will replace it with the platform’s www_dir
folder. If this value is not specified, the cwd will be used.Returns a promise that is fulfilled once the server has launched, or rejected if the server fails to launch. Once the promise is fulfilled, the following properties are available on the cordovaServe
object:
www
folder.var cordovaServe = require('cordova-serve')(); cordovaServe.launchBrowser(opts).then(function (stdout) { console.log('Browser was launched successfully: ' + stdout); }, function (error) { console.log('An error occurred: ' + error); });
Launches a browser window pointing to the specified URL. The single parameter is an options object that supports the following values (both optional):
chrome
, chromium
, firefox
, ie
, opera
, safari
. Defaults to chrome
if no browser is specified.Returns a promise that is fulfilled once the browser has been launched, or rejected if an error occurs.
The opts object passed to launchServer()
and servePlatform()
supports the following values (all optional):
ExpressJS
router. If provided, this will be attached before default static handling.true
, turns off all log output.true
, cordova-serve won't output Static file server running on...
message.EventEmitter
to use for logging. If provided, logging will be output using events.emit('log', msg)
. If not provided, console.log()
will be used. Note that nothing will be output in either case if noLogOutput
is true
.