Skip to content
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

Tweaks the yarnrc syntax parser #7210

Merged
merged 2 commits into from Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/lockfile.js
Expand Up @@ -337,7 +337,7 @@ test('parse merge conflict fail', () => {
const file = `
<<<<<<< HEAD
b:
foo: "bar"
foo "bar
=======
c:
bar "foo"
Expand Down
2 changes: 1 addition & 1 deletion src/cli/index.js
Expand Up @@ -597,7 +597,7 @@ export async function main({

async function start(): Promise<void> {
const rc = getRcConfigForCwd(process.cwd(), process.argv.slice(2));
const yarnPath = rc['yarn-path'];
const yarnPath = rc['yarn-path'] || rc['yarnPath'];

if (yarnPath && !boolifyWithDefault(process.env.YARN_IGNORE_PATH, false)) {
const argv = process.argv.slice(2);
Expand Down
24 changes: 12 additions & 12 deletions src/lockfile/parse.js
Expand Up @@ -133,7 +133,7 @@ function* tokenise(input: string): Iterator<Token> {
} else if (input[0] === ',') {
yield buildToken(TOKEN_TYPES.comma);
chop++;
} else if (/^[a-zA-Z\/-]/g.test(input)) {
} else if (/^[a-zA-Z\/.-]/g.test(input)) {
let i = 0;
for (; i < input.length; i++) {
const char = input[i];
Expand Down Expand Up @@ -286,12 +286,19 @@ class Parser {
this.next();
}

const valToken = this.token;

if (valToken.type === TOKEN_TYPES.colon) {
// object
const wasColon = this.token.type === TOKEN_TYPES.colon;
if (wasColon) {
this.next();
}

if (isValidPropValueToken(this.token)) {
// plain value
for (const key of keys) {
obj[key] = this.token.value;
}

this.next();
} else if (wasColon) {
// parse object
const val = this.parse(indent + 1);

Expand All @@ -302,13 +309,6 @@ class Parser {
if (indent && this.token.type !== TOKEN_TYPES.indent) {
break;
}
} else if (isValidPropValueToken(valToken)) {
// plain value
for (const key of keys) {
obj[key] = valToken.value;
}

this.next();
} else {
this.unexpected('Invalid value type');
}
Expand Down