Skip to content

Commit

Permalink
Resolve relative paths for root_directory
Browse files Browse the repository at this point in the history
For ./bin/juttle-service resolve relative paths for --root option into
an absolute path.

Also, in juttle-service constructor, throw error is root_directory
option is not provided or if root_directory is not an absolute path.

Closes juttle/juttle-engine#69
  • Loading branch information
Matt Nibecker committed Mar 8, 2016
1 parent 93b5b51 commit ee96c21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/juttle-service
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/* eslint no-console: 0 */
var _ = require('underscore');
var path = require('path');
var minimist = require('minimist');
var daemonize = require('daemon');
var service = require('..').service;
Expand Down Expand Up @@ -73,7 +74,7 @@ if (opts.daemonize) {

require('log4js').getLogger('juttle-service').debug('initializing');

var service_opts = {port: opts.port, root_directory: opts.root};
var service_opts = {port: opts.port, root_directory: path.resolve(opts.root)};

if (_.has(opts, 'config')) {
service_opts.config_path = opts['config'];
Expand Down
9 changes: 9 additions & 0 deletions lib/juttle-service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
var path = require('path');
var _ = require('underscore');
var express = require('express');
var logger = require('log4js').getLogger('juttle-service');
Expand Down Expand Up @@ -26,6 +27,14 @@ class JuttleService {
constructor(options) {
configure(options);

if (!options.root_directory) {
throw new Error('must provide option root_directory');
}

if (!path.isAbsolute(options.root_directory)) {
throw new Error('root_directory path must be absolute');
}

this._app = express();

this._app.disable('x-powered-by');
Expand Down

0 comments on commit ee96c21

Please sign in to comment.