@@ -15,7 +15,13 @@ async function run() {
15
15
let files = process . argv . slice ( 2 ) ;
16
16
if ( files . length === 0 ) {
17
17
console . log ( 'No file specified, validating all examples in STAC spec repository' ) ;
18
- files = await readExamples ( ) ;
18
+ files = await readExamples ( './stac-spec/' ) ;
19
+ }
20
+ else if ( files . length === 1 ) {
21
+ let stat = await fs . lstat ( files [ 0 ] ) ;
22
+ if ( stat . isDirectory ( ) ) {
23
+ files = await readExamples ( files [ 0 ] ) ;
24
+ }
19
25
}
20
26
21
27
let stats = {
@@ -77,10 +83,10 @@ async function run() {
77
83
}
78
84
}
79
85
80
- async function readExamples ( ) {
86
+ async function readExamples ( folder ) {
81
87
var files = [ ] ;
82
- for await ( let file of klaw ( './stac-spec/' ) ) {
83
- let relPath = path . relative ( './stac-spec/' , file . path ) ;
88
+ for await ( let file of klaw ( folder ) ) {
89
+ let relPath = path . relative ( folder , file . path ) ;
84
90
if ( relPath . includes ( path . sep + 'examples' + path . sep ) && path . extname ( relPath ) === '.json' ) {
85
91
files . push ( file . path ) ;
86
92
}
@@ -96,10 +102,10 @@ async function loadSchema(name) {
96
102
let file ;
97
103
switch ( name ) {
98
104
case 'core' :
99
- file = './core.json' ;
105
+ file = path . join ( __dirname , './core.json' ) ;
100
106
break ;
101
107
default :
102
- file = './stac-spec/extensions/' + name + '/json-schema/schema.json' ;
108
+ file = path . join ( __dirname , './stac-spec/extensions/' + name + '/json-schema/schema.json' ) ;
103
109
}
104
110
if ( ! await fs . exists ( file ) ) {
105
111
throw "No schema file for " + name ;
0 commit comments