Skip to content

Commit

Permalink
Tweaks the yarnrc syntax parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Maël Nison committed Apr 19, 2019
1 parent 4ad8816 commit 1863d9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
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
23 changes: 11 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,18 @@ 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 +308,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

0 comments on commit 1863d9e

Please sign in to comment.