Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ validate(minifiedCode, [sourceMap], [sourceContent]);
* `sourceContent` is a map to the raw source files
* Optional - If left empty, the inline `sourceContent` in `sourceMap` will be used

### CLI Usage

sourcemap-validate $minifiedFilePath $sourceMapFilePath

## Examples

```js
Expand Down
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env node
var validate
, validateMapping
, toAscii
, assert = require('assert')
, fs = require('fs')
, SMConsumer = require('source-map').SourceMapConsumer
, each = require('lodash.foreach')
, template = require('lodash.template')
Expand Down Expand Up @@ -74,7 +76,7 @@ validate = function (min, map, srcs) {
consumer = new SMConsumer(map);
}
catch (e) {
throw new Error('The map is not valid JSON');
throw new Error('The map is not valid JSON: ' + e);
}

each(consumer.sources, function (src) {
Expand Down Expand Up @@ -159,4 +161,10 @@ validate = function (min, map, srcs) {
assert.ok(mappingCount > 0, 'There were no mappings in the file');
};

// "main" entrypoint:
if (typeof require !== 'undefined' && require.main === module) {
validate(fs.readFileSync(process.argv[2], 'utf-8'), fs.readFileSync(process.argv[3], 'utf-8'));
process.stdout.write("Validation OK");
}

module.exports = validate;
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"scripts": {
"test": "jake test --trace"
},
"bin": {
"sourcemap-validate": "./index.js"
},
"devDependencies": {
"jake": "0.7.x",
"uglify-js": "2.4.x"
Expand Down