-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b4d4e0
commit b3663e3
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint-disable no-console */ | ||
|
||
'use strict'; | ||
|
||
const pathJoin = require('path').join, | ||
{readFile} = require('fs').promises, // eslint-disable-line node/no-unsupported-features/node-builtins | ||
readdir = require('recursive-readdir'), | ||
validate = require('sourcemap-validator'); | ||
|
||
const dirPath = pathJoin(__dirname, 'example/intermediate/example'); | ||
// const dirPath = pathJoin(__dirname, 'node_modules/is-it-type/dist'); | ||
|
||
(async () => { | ||
const paths = await readdir(dirPath); | ||
|
||
for (const path of paths) { | ||
if (!path.match(/\.js$/)) continue; | ||
|
||
const code = await readFile(path, 'utf8'); | ||
|
||
let map; | ||
const mapPath = `${path}.map`; | ||
try { | ||
map = await readFile(mapPath, 'utf8'); | ||
} catch (err) {} // eslint-disable-line no-empty | ||
|
||
const pathShort = path.slice(dirPath.length); | ||
|
||
try { | ||
validate(code, map); | ||
console.log('VALID:', pathShort); | ||
} catch (err) { | ||
if (err.message === 'No map argument provided, and no inline sourcemap found') { | ||
console.log('NO SOURCE MAP:', pathShort); | ||
} else { | ||
console.log('INVALID:', pathShort, err.message); | ||
} | ||
// console.log(path, err.message); | ||
} | ||
} | ||
})(); |