-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
manuel
committed
Mar 16, 2017
1 parent
adac69a
commit f1782db
Showing
8 changed files
with
100 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,9 @@ | |
"--path", | ||
".", | ||
"-i", | ||
".git/**/*" | ||
".git/**/*", | ||
"-o", | ||
"./test.txt" | ||
] | ||
} | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use strict"; | ||
|
||
(function(){ | ||
const fs = require('fs'); | ||
const logger = require('./logging.service'); | ||
|
||
function redirectOutput(result, parameters){ | ||
let output = parameters.output; | ||
|
||
if(output){ | ||
fs.writeFile(output, result, (error) => { | ||
if(error){ | ||
logger.error('Unable to write on: ', output); | ||
logger.debug(error); | ||
return; | ||
} | ||
|
||
logger.info('Successfully written: ', output) | ||
}); | ||
} | ||
else{ | ||
return result | ||
} | ||
} | ||
|
||
module.exports = { redirectOutput } | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use strict"; | ||
|
||
(function () { | ||
const { expect } = require('chai'); | ||
const sinon = require('sinon'); | ||
const fs = require('fs'); | ||
const service = require('./redirect-output.service'); | ||
const logger = require('./logging.service'); | ||
const Parameters = require('../model/parameters.model'); | ||
|
||
describe('Service: ReedirectOutput', () => { | ||
logger.setLogLevel(3); | ||
it('should be defined', () => { | ||
expect(!!service).to.equal(true); | ||
}); | ||
|
||
describe('Method: redirectOutput', () => { | ||
it('should be defined', () => { | ||
expect(!!service.redirectOutput).to.equal(true); | ||
}); | ||
|
||
it('should return a string if no output is provided', () => { | ||
let x = service.redirectOutput('asd', new Parameters()); | ||
|
||
expect(x).to.equal('asd'); | ||
}) | ||
|
||
it('should call fs.writeFile if output is provided', () => { | ||
let params = new Parameters(); | ||
params.output = '.'; | ||
|
||
let fsStub = sinon.stub(fs, 'writeFile'); | ||
|
||
service.redirectOutput('asdf', params); | ||
|
||
expect(fsStub.called).to.equal(true); | ||
}) | ||
}) | ||
}) | ||
}()); |