Giter Site home page Giter Site logo

wsl_build's Introduction

WSL Build

This Sublime Text Package facilitates writing custom builds for projects running in WSL2. It adds a "wsl_exec" target for build commands that does the following:

  • execute Linux commands
  • provides Linux paths in variables such as $file
  • properly set ENV variables for Linux commands

For more information about defining Sublime Text builds see the official documentation

Defining a Build

set "target": "wsl_exec"

Required Keys

Set "wsl_cmd" instead of "cmd". The command array will be executed through WSL. Build variables such as $file will have Linux paths.

Optional Keys

Set "wsl_working_dir" instead of "working_dir". Build variables such as $file will have Linux paths.

Set "wsl_env" instead of "env" to set environment variables that are available to the Linux command. Build variables such as $file will have Linux paths.

Example Builds for a Rails app in WSL:

"build_systems": [
    {
        "name": "๐Ÿงช Run Current Spec",
        "target": "wsl_exec",
        "wsl_cmd": [
            "bundle", "exec", "rake", "spec" 
        ],
        "wsl_env": {
            "SPEC": "$file"
        },
        "wsl_working_dir": "$folder"
    },
    {
        "name": "๐Ÿงช Run All Specs",
        "target": "wsl_exec",
        "wsl_cmd": [
            "bundle", "exec", "rake", "spec"
        ],
        "wsl_working_dir": "$folder",
    },
    {
        "name": "๐Ÿ—ƒ๏ธ Run Database Migrations",
        "target": "wsl_exec",
        "wsl_cmd": [
            "bundle", "exec", "rake", "db:migrate"
        ],
        "wsl_working_dir": "$folder"
    }

Acknowledgments

Inspired by OdatNurd's technique here https://github.com/STealthy-and-haSTy/SublimeScraps/blob/master/build_enhancements/custom_build_variables.py

wsl_build's People

Contributors

existentialmutt avatar

Watchers

 avatar  avatar

wsl_build's Issues

Invalid `wsl_env` treatment.

According to https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows WSLENV is a colon separated list of existing environment variables to share between Windows ans WSL.

Each entry can be specified with a flag defining how it is to be translated between Windows and WSL.

How to share existing windows enviornment variables using those flags?

How to specify flags for user defined key value pairs?

Maybe by specifying the flag in a variables name?

	"wsl_env": {
		"profile/p": "%USERPROFILE%",
	},

It would need to be stripped from normal "env" then.

insufficient WSL path conversion

wsl_build/wsl_build.py

Lines 77 to 79 in ef0e282

def wsl_path(self, string):
prefix_removed = re.sub("\\\\\\\\wsl.localhost\\\\Ubuntu", "", string)
return re.sub("\\\\", "/", prefix_removed)

The path translation ...

  1. works only for a very specific WSL distribution. How about Debian or other distros?
  2. doesn't take files into account, which are located in normal windows like folders (e.g.: C:\Foo\Bar\baz.txt)

Opt-in to python 3.8

Any new plugin should provide a .python-version with 3.8 as content, to opt-in to ST4's python 3.8 plugin_host.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.