Skip to content

Removed leading '../' from path when unpacking #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ if (!fs.existsSync(pathToMap)) {
try {
const mapFile = fs.readFileSync(pathToMap, 'utf8')
SourceMapConsumer.with(mapFile, null, (consumer: SourceMapConsumer) => {
console.log(chalk.green(`Unpacking 🛍 your source maps 🗺`))
const sources = (consumer as any).sources
sources.forEach((source: string) => {
const WEBPACK_SUBSTRING_INDEX = 11
const content = consumer.sourceContentFor(source)
const filePath = `${process.cwd()}/${projectNameInput}/${source.substring(WEBPACK_SUBSTRING_INDEX)}`
var sanitizeRE = /^\.\.\//;
console.log(chalk_1.default.green("Unpacking \uD83D\uDECD your source\u00A0maps \uD83D\uDDFA"));
var sources = consumer.sources;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's probably better to stict to ES6 lets and consts instead of an outdated var.

sources.forEach(function (source) {
console.log(chalk_1.default.green(source));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be chalk.green(source)?

console.log(chalk_1.default.green(source.replace( sanitizeRE, '')));
var content = consumer.sourceContentFor(source);
var filePath = process.cwd() + "/" + projectNameInput + "/" + source.replace(sanitizeRE, '');
mkdirp.sync(dirname(filePath))
fs.writeFileSync(filePath, content)
})
Expand Down