Skip to content

Commit

Permalink
Normalize path arguments (#84)
Browse files Browse the repository at this point in the history
-Trim extra `'`
  • Loading branch information
nikolay-borzov committed Apr 10, 2019
1 parent b036e59 commit 5e018d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ interface Arguments {
}

function parseArguments(): Arguments {
// TODO: Use `middleware` to remove extra single quotes from positional arguments
return yargs
const argv = yargs
.strict()
.scriptName('source-map-explorer')
.usage('Analyze and debug space usage through source maps.')
Expand Down Expand Up @@ -94,6 +93,12 @@ function parseArguments(): Arguments {
return true;
})
.parse();

// Trim extra quotes
const quoteRegex = /'/g;
argv._ = argv._.map(path => path.replace(quoteRegex, ''));

return argv;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('CLI', function() {
}
});

it('should print result as JSON', async function() {
const result = await execute(SCRIPT_PATH, ['data/foo.min.inline-map.js', '--json']);
it('should print result as JSON and support path wrapped by quotes', async function() {
const result = await execute(SCRIPT_PATH, ["'data/foo.min.inline-map.js'", '--json']);

expect(result).to.matchSnapshot();
});
Expand Down
2 changes: 1 addition & 1 deletion tests/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ exports[`CLI should output result as tsv 1`] = `
"
`;
exports[`CLI should print result as JSON 1`] = `
exports[`CLI should print result as JSON and support path wrapped by quotes 1`] = `
"{
\\"node_modules/browserify/node_modules/browser-pack/_prelude.js\\": 463,
\\"dist/bar.js\\": 2854,
Expand Down

0 comments on commit 5e018d3

Please sign in to comment.