How to use the line-column-path.parse function in line-column-path

To help you get started, we’ve selected a few line-column-path examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / open-editor / index.js View on Github external
const make = (files, options = {}) => {
	if (!Array.isArray(files)) {
		throw new TypeError(`Expected an \`Array\`, got ${typeof files}`);
	}

	const editor = options.editor ? envEditor.getEditor(options.editor) : envEditor.defaultEditor();
	const editorArguments = [];

	if (editor.id === 'vscode') {
		editorArguments.push('--goto');
	}

	for (const file of files) {
		const parsed = lineColumnPath.parse(file);

		if (['sublime', 'atom', 'vscode'].includes(editor.id)) {
			editorArguments.push(lineColumnPath.stringify(parsed));
			continue;
		}

		if (['webstorm', 'intellij'].includes(editor.id)) {
			editorArguments.push(lineColumnPath.stringify(parsed, {column: false}));
			continue;
		}

		if (editor.id === 'textmate') {
			editorArguments.push('--line', lineColumnPath.stringify(parsed, {
				file: false
			}), parsed.file);
			continue;

line-column-path

Parse and stringify file paths with line and column like `unicorn.js:8:14`

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular line-column-path functions