Skip to content

Commit

Permalink
Remove spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdouglas committed Oct 2, 2015
1 parent c456aeb commit 786e252
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
var path = require( 'path' );
var path = require('path');

function rooted( pathTo, onlyString ) {
function rooted(pathTo, onlyString) {
var splitBy = '/';
var args;

if ( pathTo.search( /\\/ ) >= 0 ) {
if (pathTo.search(/\\/) >= 0) {
pathTo = pathTo.replace( /\\/g, splitBy );
}

var actualPath = __dirname + '/' + pathTo;
actualPath = actualPath.replace( '/node_modules/rooted', '' );
actualPath = actualPath.replace('/node_modules/rooted', '');

if (onlyString) {
return actualPath;
} else {
return require( actualPath );
return require(actualPath);
}
};

Expand Down
26 changes: 13 additions & 13 deletions test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
var expect = require( 'chai' ).expect;
var path = require( 'path' );
var rooted = require( '../' );
var example = rooted( 'example' );
var folder = rooted( 'example\\folder' );
var stringPath = rooted( 'path/to/folder', true );
var expect = require('chai').expect;
var path = require('path');
var rooted = require('../');
var example = rooted('example');
var folder = rooted('example\\folder');
var stringPath = rooted('path/to/folder', true);

describe( '#rooted', function() {
describe('#rooted', function() {

it( 'Should return the path to a file based on its root directory', function() {
expect( example() ).to.equal( 'example index.js' );
it('Should return the path to a file based on its root directory', function() {
expect(example()).to.equal('example index.js');
});

it( 'Should return the path to a file based on its root directory', function() {
expect( folder() ).to.equal( 'example/folder index.js' );
it('Should return the path to a file based on its root directory', function() {
expect(folder()).to.equal('example/folder index.js');
});

it('Should return a string for the path of the file', function() {
var testPath = __dirname + '/path/to/folder';
testPath = testPath.replace( '/test', '' );
expect( stringPath ).to.equal( testPath );
testPath = testPath.replace('/test', '');
expect(stringPath).to.equal(testPath);
});

});

0 comments on commit 786e252

Please sign in to comment.