pucelle / vscode-run-on-save

Run configured shell commands when a file is saved in vscode, and output configured messages on status bar.
https://marketplace.visualstudio.com/items?itemName=pucelle.run-on-save
MIT License
50 stars 11 forks source link

add right slash transform #12

Closed tomByrer closed 3 years ago

tomByrer commented 3 years ago

Deno doesn't like left-slashes \ on Windows for some reason. So locally I added:

...
            piece = piece.replace(/\${fileRightslash}/g, this.rightSlash(filePath));
            piece = piece.replace(/\${fileRelativeRightslash}/g, this.rightSlash(path.
...
    rightSlash(filePath) {
        let dir = filePath.replace(/\\/g, '/');
        if (!dir) {
            dir = filePath[0] || '';
        }
        return dir;
    }

I don't know if that's the API you would like to add, but I needed it to get your handy plugin to work with Deno. I was about to make a PR, but I don't know TS yet.

cheers

pucelle commented 3 years ago

How about a new command option: forceSlash = / or \ or Platform Specified?

tomByrer commented 3 years ago

"command option: forceSlash" sounds good, but I needed to get around my platform (Win) standard of \.

pucelle commented 3 years ago

I add a new option forcePathSeparator and release v1.4.0.