@@ -51,7 +51,23 @@ $ js-source-extractor file:///tmp/embedded-sourcemap-test.js
5151 Extracting embedded source map
5252 Source map references 1 source files
5353 Source /tmp/extract/src/embedded-sourcemap-test.ts written
54+ ```
5455
56+ Help output from the CLI
57+ ``` bash
58+ $ js-source-extractor.js --help
59+
60+ Usage: js-source-extractor [options] < resourceUrl>
61+
62+ Extracts source from javascript frameworks with sourcemap information (containing the source)
63+
64+ Options:
65+
66+ -v, --version output the version number
67+ -o, --outDir < outDir> Base output directory where source files should be output to
68+ -i, --include < includePattern> Include pattern to apply when selecting source files for extraction
69+ -e, --exclude < excludePattern> Exclude pattern to apply when selecting source files for extraction (executed after include pattern)
70+ -h, --help output usage information
5571```
5672
5773## Install as node module to use in your own project
@@ -63,10 +79,10 @@ $ npm install --save-dev js-source-extractor
6379To extract source code from a sourcemap embedded in a javascript and call a callback per source file, use:
6480
6581``` typescript
82+ import { URL } from " url" ;
6683import { extractSrc } from ' js-source-extractor'
6784
68- const baseDir = __dirname + " /../resources" ;
69- extractSrc (new URL (util .format (' file://%s/embedded-sourcemap-test.js' , baseDir )), null , (path : string , sourceName : string , source : string | null ) => {
85+ extractSrc (new URL (' https://raw.githubusercontent.com/unblu/js-source-extractor/master/resources/embedded-sourcemap-test.js' ), null , (path : string , sourceName : string , source : string | null ) => {
7086 console .log (" Path: " + path ); // '/src'
7187 console .log (" SourceName: " + sourceName ); // '/embedded-sourcemap-test.ts'
7288 console .log (" Source: " + source ); // 'console.log(\'Hello World!\');'
@@ -75,9 +91,12 @@ extractSrc(new URL(util.format('file://%s/embedded-sourcemap-test.js', baseDir))
7591
7692To extract code from a sourcemap embedded in a javascript and write the source files to the disk, use:
7793``` typescript
78- const baseDir = __dirname + " /../resources" ;
79- const outDir = tmpdir () + path .sep + ' js-source-extractor-test' ; // directory to store source files in
80- await extractSrcToDir (new URL (util .format (' file://%s/embedded-sourcemap-test.js' , baseDir )), outDir );
94+ import { tmpdir } from " os" ;
95+ import { URL } from " url" ;
96+ import { extractSrcToDir } from ' js-source-extractor'
97+
98+ const outDir = tmpdir () + ' /js-source-extractor-test' ; // directory to store source files in
99+ await extractSrcToDir (new URL (' https://raw.githubusercontent.com/unblu/js-source-extractor/master/resources/embedded-sourcemap-test.js' ), outDir );
81100```
82101
83102## Running the tests
@@ -87,7 +106,6 @@ JS Source Extractor features a number of mocha tests to verify the various API f
87106To start the tests, use:
88107```
89108$ npm test
90-
91109```
92110
93111## Contributing
@@ -102,7 +120,21 @@ See also the list of [contributors](https://github.com/unblu/js-source-extractor
102120
103121## License
104122
105- This project is licensed under the ISC License - see the [ LICENSE.md] ( LICENSE ) file for details
123+ This project is licensed under the ISC License
124+
125+ Copyright (c) 2018, Kay Huber, unblu inc.
126+
127+ Permission to use, copy, modify, and/or distribute this software for any
128+ purpose with or without fee is hereby granted, provided that the above
129+ copyright notice and this permission notice appear in all copies.
130+
131+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
132+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
133+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
134+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
135+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
136+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
137+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
106138
107139## Acknowledgments
108140
0 commit comments