Skip to content

Commit

Permalink
fix: Give the schema-drafts.js proper name and path in source maps
Browse files Browse the repository at this point in the history
It appears, that uglify.js always uses the path from the command-line
source file. Changing it by a command-line parameter does not work.
It means that files cannot be miniified by piping them to uglifyjs.
  • Loading branch information
prantlf committed Jun 16, 2019
1 parent 72b1674 commit c2f0148
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -34,7 +34,7 @@
"scripts": {
"prepare": "npm run lint && npm run build",
"lint": "standard --fix -v",
"build": "node scripts/bundle-jsonlint && uglifyjs -o web/jsonlint.min.js --source-map \"filename='jsonlint.js',url='jsonlint.min.js.map',includeSources=true\" lib/jsonlint.js && uglifyjs -o web/validator.min.js --source-map \"filename='validator.js',url='validator.min.js.map',includeSources=true\" lib/validator.js && uglifyjs -o web/formatter.min.js --source-map \"filename='formatter.js',url='formatter.min.js.map',includeSources=true\" lib/formatter.js && uglifyjs -o web/sorter.min.js --source-map \"filename='sorter.js',url='sorter.min.js.map',includeSources=true\" lib/sorter.js && node scripts/bundle-schema-drafts | uglifyjs -o web/schema-drafts.min.js --source-map \"filename='schema-drafts.js',url='schema-drafts.min.js.map',includeSources=true\" && uglifyjs -o web/ajv.min.js --source-map \"filename='ajv.js',url='ajv.min.js.map',includeSources=true\" node_modules/ajv/dist/ajv.bundle.js",
"build": "node scripts/bundle-jsonlint && uglifyjs -o web/jsonlint.min.js --source-map \"filename='jsonlint.js',url='jsonlint.min.js.map',includeSources=true\" lib/jsonlint.js && uglifyjs -o web/validator.min.js --source-map \"filename='validator.js',url='validator.min.js.map',includeSources=true\" lib/validator.js && uglifyjs -o web/formatter.min.js --source-map \"filename='formatter.js',url='formatter.min.js.map',includeSources=true\" lib/formatter.js && uglifyjs -o web/sorter.min.js --source-map \"filename='sorter.js',url='sorter.min.js.map',includeSources=true\" lib/sorter.js && node scripts/bundle-schema-drafts && uglifyjs -o web/schema-drafts.min.js --source-map \"filename='schema-drafts.js',url='schema-drafts.min.js.map',includeSources=true\" lib/schema-drafts.js && uglifyjs -o web/ajv.min.js --source-map \"filename='ajv.js',url='ajv.min.js.map',includeSources=true\" node_modules/ajv/dist/ajv.bundle.js",
"test": "nyc --silent node test/parse1 && nyc --silent --no-clean node test/parse1 --native-parser && nyc --silent --no-clean node test/parse2 && nyc --silent --no-clean node test/parse3 && nyc --silent --no-clean node test/parse4 && nyc --silent --no-clean node test/parse5 && nyc --silent --no-clean node test/portable && nyc --silent --no-clean node lib/cli package.json test/recursive && nyc --silent --no-clean node lib/cli -sq test/passes/hasOwnProperty.json && nyc --silent --no-clean node lib/cli -s -e json-schema-draft-04 -V test/passes/3.schema.json test/passes/3.json && nyc --silent --no-clean node lib/cli -C test/passes/comments.txt && nyc --silent --no-clean node lib/cli -S test/passes/strings.txt && nyc --silent --no-clean node lib/cli -M json5 test/passes/json5.text && nyc --silent --no-clean node lib/cli -v && nyc --silent --no-clean node lib/cli -h && nyc --silent --no-clean node lib/cli -pc test/fails/10.json || nyc report",
"test:old": "node test/parse1 && node test/parse1 --native-parser && node test/parse2 && node test/parse3 && node test/parse4 && node test/parse5 && node test/portable && node lib/cli package.json test/recursive && node lib/cli -sq test/passes/hasOwnProperty.json && node lib/cli -s -e json-schema-draft-04 -V test/passes/3.schema.json test/passes/3.json && node lib/cli -C test/passes/comments.txt && node lib/cli -S test/passes/strings.txt && node lib/cli -M json5 test/passes/json5.text && node lib/cli -v && node lib/cli -h",
"coverage": "cat coverage/lcov.info | npx coveralls",
Expand Down
6 changes: 4 additions & 2 deletions scripts/bundle-schema-drafts.js
Expand Up @@ -16,9 +16,11 @@ var environments = [
'json-schema-draft-06',
'json-schema-draft-07'
]
var source = environments.map(function (environment) {
var input = environments.map(function (environment) {
var file = path.join(__dirname, '../node_modules/ajv/lib/refs/' + environment + '.json')
var code = fs.readFileSync(file)
return 'exports["' + environment + '"] = ' + code
})
console.log(prefix + source.join('\n') + suffix)
var output = prefix + input.join('\n') + suffix
var file = path.join(__dirname, '../lib/schema-drafts.js')
fs.writeFileSync(file, output)

0 comments on commit c2f0148

Please sign in to comment.