This repository was archived by the owner on Sep 21, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,10 @@ Rejects promise if critical error occurred.
205205
206206* ` gemini.browserIds ` – list of all browser identificators to use for tests.
207207
208+ * ` Gemini.readRawConfig ` - reads configuration file for specified ` filePath `
209+ and returns content as JS object. This method does not validate and analyze
210+ gemini configuration.
211+
208212## Events
209213
210214` gemini ` instance emits some events, which can be used by external scripts or
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ Config.prototype.isCoverageEnabled = function() {
5555 return this . system . coverage . enabled ;
5656} ;
5757
58+ Config . readRawConfig = readConfig ;
59+
5860function readConfig ( filePath ) {
5961 var config = configReader . read ( filePath ) ,
6062 configDir = filePath ? path . dirname ( filePath ) : process . cwd ( ) ;
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ module.exports = class Gemini extends PassthroughEmitter {
3838 this . _loadPlugins ( ) ;
3939 }
4040
41+ static readRawConfig ( filePath ) {
42+ return Config . readRawConfig ( filePath ) ;
43+ }
44+
4145 _run ( stateProcessor , paths , options ) {
4246 if ( ! options ) {
4347 //if there are only two arguments, they are
Original file line number Diff line number Diff line change @@ -18,9 +18,21 @@ describe('config', function() {
1818 assert . calledWith ( configReader . read , '/some/path' ) ;
1919 } ) ;
2020
21+ it ( 'should have static API for reading of a configuration file' , ( ) => {
22+ sandbox . stub ( configReader , 'read' )
23+ . withArgs ( '/some/path' )
24+ . returns ( { foo : 'bar' } ) ;
25+
26+ assert . deepEqual ( Config . readRawConfig ( '/some/path' ) , {
27+ foo : 'bar' ,
28+ system : {
29+ projectRoot : '/some'
30+ }
31+ } ) ;
32+ } ) ;
33+
2134 describe ( 'overrides' , function ( ) {
2235 beforeEach ( function ( ) {
23- /*jshint -W069*/
2436 this . configValue = '/from/config' ;
2537 this . envValue = '/from/env' ;
2638 this . cliValue = '/from/cli' ;
@@ -42,7 +54,6 @@ describe('config', function() {
4254 } ) ;
4355
4456 afterEach ( function ( ) {
45- /*jshint -W069*/
4657 delete process . env [ 'gemini_system_project_root' ] ;
4758 process . argv = this . oldArgv ;
4859 } ) ;
Original file line number Diff line number Diff line change @@ -336,4 +336,18 @@ describe('gemini', () => {
336336 . then ( ( ) => assert . calledWith ( console . warn , sinon . match ( 'Unknown browsers id: b2' ) ) ) ;
337337 } ) ;
338338 } ) ;
339+
340+ describe ( 'readRawConfig' , ( ) => {
341+ beforeEach ( ( ) => {
342+ sandbox . stub ( Config , 'readRawConfig' ) ;
343+ } ) ;
344+
345+ it ( 'should read configuration object from file by given path' , ( ) => {
346+ Config . readRawConfig
347+ . withArgs ( 'some/file/path' )
348+ . returns ( { foo : 'bar' } ) ;
349+
350+ assert . deepEqual ( Gemini . readRawConfig ( 'some/file/path' ) , { foo : 'bar' } ) ;
351+ } ) ;
352+ } ) ;
339353} ) ;
You can’t perform that action at this time.
0 commit comments