-
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.
[config] Support resolve external ref #4
- didn't use library for resolve $ref - all path are transformed to full path in Parser - add a Stack class to deal with relative path in $ref values, ie: in example/data/people.yml $ref : sway.yml means example/data/sway.yml instead of ./sway.yml
- Loading branch information
Showing
8 changed files
with
240 additions
and
10 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
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,27 @@ | ||
/** | ||
* Created by at15 on 2016/9/7. | ||
*/ | ||
'use strict'; | ||
|
||
class Stack { | ||
constructor() { | ||
this.data = []; | ||
this.len = 0; | ||
} | ||
|
||
push(ele) { | ||
this.data[this.len] = ele; | ||
this.len++; | ||
} | ||
|
||
pop() { | ||
this.len--; | ||
return this.data[this.len]; | ||
} | ||
|
||
top() { | ||
return this.data[this.len - 1]; | ||
} | ||
} | ||
|
||
module.exports = Stack; |
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,17 @@ | ||
'use strict'; | ||
const expect = require('chai').expect; | ||
const fsUtil = require('../../lib/util/fs'); | ||
|
||
describe('fs util', ()=> { | ||
it('resolve partial path to current folder', () => { | ||
expect(fsUtil.fullPath('test/util/fs-spec.js')).to.eql(__filename); | ||
}); | ||
|
||
it('leave path with current folder prefix as it is', () => { | ||
expect(fsUtil.fullPath(__filename)).to.eql(__filename); | ||
}); | ||
|
||
it('has shortcut for get file directory', () => { | ||
expect(fsUtil.dir(__filename)).to.eql(__dirname); | ||
}) | ||
}); |
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,23 @@ | ||
/** | ||
* Created by at15 on 2016/9/7. | ||
*/ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const Stack = require('../../lib/util/stack'); | ||
|
||
describe('Stack', ()=> { | ||
it('can push and pop', () => { | ||
let s = new Stack(); | ||
s.push(1); | ||
expect(s.pop()).to.eqls(1); | ||
}); | ||
|
||
it('use top to return last value', () => { | ||
let s = new Stack(); | ||
s.push(1); | ||
s.push(2); | ||
expect(s.top()).to.eqls(2); | ||
expect(s.top()).to.eqls(2); | ||
}); | ||
}); |