Skip to content

Commit

Permalink
Allow schemaMap arg as array, update shorthand extension names
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Mar 18, 2021
1 parent 8962c7d commit b375b76
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,22 @@ const package = require('./package.json');
let DEBUG = false;
let COMPILED = {};
let SHORTCUTS = [
'card4l-eo',
'card4l-sar',
'checksum', // legacy
'collection-assets',
'datacube',
'collection-assets', // now in core
'datacube', // now in stac-extensions org
'eo',
'file',
'item-assets',
'label',
'pointcloud',
'processing',
'item-assets', // now in stac-extensions org
'label', // now in stac-extensions org
'pointcloud', // now in stac-extensions org
'processing', // now in stac-extensions org
'projection',
'sar',
'sat',
'sar', // now in stac-extensions org
'sat', // now in stac-extensions org
'scientific',
'single-file-stac',
'tiled-assets',
'timestamps',
'version',
'single-file-stac', // now in stac-extensions org
'tiled-assets', // now in stac-extensions org
'timestamps', // now in stac-extensions org
'version', // now in stac-extensions org
'view'
];
let ajv = new Ajv({
Expand Down Expand Up @@ -78,17 +75,23 @@ async function run() {
}
}

if (typeof args.schemaMap === 'string') {
let map = args.schemaMap.split(';');
for(let row of map) {
let parts = row.split("=");
let stat = await fs.lstat(parts[1]);
if (stat.isFile()) {
schemaMap[parts[0]] = parts[1];
}
else {
console.error(`Schema mapping for ${parts[0]} is not a valid file: ${parts[1]}`);
}
let schemaMapArgs = [];
if (Array.isArray(args.schemaMap)) {
// Recommended way
schemaMapArgs = args.schemaMap;
}
else if (typeof args.schemaMap === 'string') {
// Backward compliance
schemaMapArgs = args.schemaMap.split(';');
}
for(let arg of schemaMapArgs) {
let parts = arg.split("=");
let stat = await fs.lstat(parts[1]);
if (stat.isFile()) {
schemaMap[parts[0]] = parts[1];
}
else {
console.error(`Schema mapping for ${parts[0]} is not a valid file: ${parts[1]}`);
}
}

Expand Down

0 comments on commit b375b76

Please sign in to comment.