lib/parser.js
function parseLine(line, lineno, options) {
	let command = null;
	const lineContinuationRegex = (options && options.lineContinuationRegex
		|| TOKEN_LINE_CONTINUATION);

	line = line.trim();

	if (!line) {
		// Ignore empty lines
		return { command: null, remainder: '' };
	}

	if (isComment(line)) {
		// Handle comment lines.
		command = { name: 'COMMENT', args: line, lineno: lineno };
		return { command: command, remainder: '' };
	}

	if (line.match(lineContinuationRegex)) {
		// Line continues on next line.
		const remainder = line.replace(lineContinuationRegex, '', 'g');
		return { command: null, remainder: remainder };
	}

	command = splitCommand(line);
	command.lineno = lineno;

	let commandParserFn = commandParsers[command.name];
	if (!commandParserFn) {
		// Invalid Dockerfile instruction, but allow it and move on.
		// log.debug('Invalid Dockerfile command:', command.name);
		commandParserFn = parseString;
	}

	if (commandParserFn(command)) {
		// Successfully converted the arguments.
		command.raw = line;
		delete command.rest;
	}

	return { command: command, remainder: '' };
}
function parseLine(line, lineno, options) {
	let command = null;
	const lineContinuationRegex = (options && options.lineContinuationRegex
		|| TOKEN_LINE_CONTINUATION);

	line = line.trim();

	if (!line) {
		// Ignore empty lines
		return { command: null, remainder: '' };
	}

	if (isComment(line)) {
		// Handle comment lines.
		command = { name: 'COMMENT', args: line, lineno: lineno };
		return { command: command, remainder: '' };
	}

	if (line.match(lineContinuationRegex)) {
		// Line continues on next line.
		const remainder = line.replace(lineContinuationRegex, '', 'g');
		return { command: null, remainder: remainder };
	}

	command = splitCommand(line);
	command.lineno = lineno;

	let commandParserFn = commandParsers[command.name];
	if (!commandParserFn) {
		// Invalid Dockerfile instruction, but allow it and move on.
		// log.debug('Invalid Dockerfile command:', command.name);
		commandParserFn = parseString;
	}

	if (commandParserFn(command)) {
		// Successfully converted the arguments.
		command.raw = line;
		delete command.rest;
	}

	return { command: command, remainder: '' };
}
function parseLine ( line , lineno , options ) { let command = null ; const lineContinuationRegex = ( options && options . lineContinuationRegex || TOKEN_LINE_CONTINUATION ) ; line = line . trim ( ) ; if ( ! line ) { // Ignore empty lines return { command : null , remainder : '' } ; } if ( isComment ( line ) ) { // Handle comment lines. command = { name : 'COMMENT' , args : line , lineno : lineno } ; return { command : command , remainder : '' } ; } if ( line . match ( lineContinuationRegex ) ) { // Line continues on next line. const remainder = line . replace ( lineContinuationRegex , '' , 'g' ) ; return { command : null , remainder : remainder } ; } command = splitCommand ( line ) ; command . lineno = lineno ; let commandParserFn = commandParsers [ command . name ] ; if ( ! commandParserFn ) { // Invalid Dockerfile instruction, but allow it and move on. // log.debug('Invalid Dockerfile command:', command.name); commandParserFn = parseString ; } if ( commandParserFn ( command ) ) { // Successfully converted the arguments. command . raw = line ; delete command . rest ; } return { command : command , remainder : '' } ; }
parse a line and return the remainder.
parse a line and return the remainder .