terriajs-schema
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "terriajs-schema", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "JSON schema for TerriaJS.", | ||
@@ -5,0 +5,0 @@ "main": "validate.js", |
@@ -5,5 +5,5 @@ /*jshint -W030 */ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var defaultVersion = 'master'; | ||
var schemaBasePath = 'schema'; | ||
var argv = require('yargs') | ||
@@ -24,3 +24,3 @@ .usage('$0 [--version <version>] <catalog.json> [<anothercatalog.json> ...]') | ||
try { | ||
argv.version = require( (argv.terriajsdir.match(/^[.\/]/) ? '' : './') + argv.terriajsdir + '/package.json').version; | ||
argv.version = JSON.parse(fs.readFileSync(path.join(argv.terriajsdir, 'package.json'), 'utf8')).version; | ||
} catch (e) { | ||
@@ -34,3 +34,3 @@ console.warn(e.message); | ||
var path = argv.version; | ||
var schemaPath = path.join(schemaBasePath, argv.version); | ||
@@ -81,11 +81,11 @@ var rootSchema; | ||
function loadNextSchema(filename, callback) { | ||
fs.readFile(path + '/' + filename, 'utf8', function(err, data) { | ||
fs.readFile(path.join(schemaPath, filename), 'utf8', function(err, data) { | ||
if (err) { | ||
console.log(); | ||
if (filename === 'Catalog.json' && argv.version !== defaultVersion) { | ||
path = defaultVersion; | ||
console.warn("WARNING: We don't have a schema for version '" + argv.version + "'. Falling back to '" + path + "'."); | ||
schemaPath = path.join(schemaBasePath, defaultVersion); | ||
console.warn("WARNING: We don't have a schema for version '" + argv.version + "'. Falling back to '" + defaultVersion + "'."); | ||
loadNextSchema(filename, callback); | ||
} else { | ||
console.error("ERROR: Missing file " + path + '/' + filename); | ||
console.error("ERROR: Missing file " + path.join(schemaPath, filename)); | ||
process.exit(1); | ||
@@ -112,3 +112,3 @@ } | ||
} | ||
argv.quiet || process.stdout.write('Loading schema: ' + path + '/Catalog.json ... '); | ||
argv.quiet || process.stdout.write('Loading schema: ' + path.join(schemaPath, '/Catalog.json ... ')); | ||
loadNextSchema('Catalog.json', validate); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
137317
73
3903
1
1