Skip to content

Wrong luacheck cwd is used with --config #96

Description

@Nexela

When a .luacheckrc file is automaticly detected it passes the cwd of the file. In this case the cwd of the .luacheckrc file should be used.

This rough js change allows it to work correctly

class Luacheck {
    constructor(coder) {
        this.coder = coder;
    }

    command(document) {
        const settings = this.coder.settings.luacheck;
        let args = [];
        let luacheckrc_path

        if (settings.automaticOption) {
            this.automaticOptions(settings, args, document);
        } else {
            const luacheckrc = path_1.resolve(settings.configFilePath, ".luacheckrc");
            if (isFileSync(luacheckrc)) {
                args.push('--config', luacheckrc);
                luacheckrc_path = path_1.dirname(luacheckrc)
            }
        }

        args.push(...defaultOpt);
        const fileName = uri_1.parse(document.uri).fsPath;
        args.push("--filename", fileName, "-"); //use stdin

        let cmd = settings.execPath || default_luacheck_executor;
        let cwd = path_1.dirname(luacheckrc_path || fileName);

        return {
            cmd: cmd,
            cwd: cwd,
            args: args
        };
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions