Browse Source

imporst from @pal-alex:

* VSCode support
* handle empty [] tags
Namdak Tonpa 6 years ago
parent
commit
61d7b85b5e
5 changed files with 20 additions and 4 deletions
  1. 1 1
      include/mad.hrl
  2. BIN
      mad
  3. 8 0
      make.bat
  4. 10 2
      src/provision/mad_repl.erl
  5. 1 1
      src/sources/mad_git.erl

+ 1 - 1
include/mad.hrl

@@ -1 +1 @@
--define(VERSION,"816513").
+-define(VERSION,"c3523f").

BIN
mad


+ 8 - 0
make.bat

@@ -0,0 +1,8 @@
+@echo off
+Setlocal EnableDelayedExpansion
+FOR /F "delims==" %%I IN ('git rev-parse HEAD ^| head -c 6') DO (
+     < nul set /p str="-define(VERSION, "%%I%")." > include/mad.hrl
+)
+@echo on
+escript.exe mad cle dep com bun mad
+pause

+ 10 - 2
src/provision/mad_repl.erl

@@ -6,6 +6,9 @@ disabled() -> [].
 system() -> [compiler,syntax_tools,sasl,tools,mnesia,reltool,xmerl,crypto,kernel,stdlib,ssh,eldap,
 system() -> [compiler,syntax_tools,sasl,tools,mnesia,reltool,xmerl,crypto,kernel,stdlib,ssh,eldap,
              wx,ssl,runtime_tools,public_key,observer,inets,asn1,et,eunit,hipe,os_mon,parsetools,odbc,snmp].
              wx,ssl,runtime_tools,public_key,observer,inets,asn1,et,eunit,hipe,os_mon,parsetools,odbc,snmp].
 
 
+escript_name() ->
+    try escript:script_name() of N -> N catch _:_ -> [] end.
+
 local_app() ->
 local_app() ->
     case filename:basename(filelib:wildcard("ebin/*.app"),".app") of
     case filename:basename(filelib:wildcard("ebin/*.app"),".app") of
          [] -> [];
          [] -> [];
@@ -98,8 +101,13 @@ sh(Params) ->
               ++ string:join([atom_to_list(X)||X<-mad_repl:system()],",") ++ "}-*/ebin"),
               ++ string:join([atom_to_list(X)||X<-mad_repl:system()],",") ++ "}-*/ebin"),
     UserPath   = wildcards(["{apps,deps}/*/ebin","ebin"]),
     UserPath   = wildcards(["{apps,deps}/*/ebin","ebin"]),
     code:set_path(SystemPath++UserPath),
     code:set_path(SystemPath++UserPath),
-    code:add_path(filename:join([cwd(),filename:basename(escript:script_name())])),
-    load(),
+
+    case escript_name() of
+        [] -> ok; % VSCode
+         N -> code:add_path(filename:join([cwd(),filename:basename(N)])),
+              load()
+    end,
+
     Config = load_sysconfig(),
     Config = load_sysconfig(),
     application_config(Config),
     application_config(Config),
     Driver = mad_utils:get_value(shell_driver,_Config,user_drv),
     Driver = mad_utils:get_value(shell_driver,_Config,user_drv),

+ 1 - 1
src/sources/mad_git.erl

@@ -30,7 +30,7 @@ fetch(Cwd, Config, ConfigFile, [H|T]) ->
          {error,E} -> {error,E};
          {error,E} -> {error,E};
          {ok,_} -> fetch(Cwd, Config, ConfigFile, T) end.
          {ok,_} -> fetch(Cwd, Config, ConfigFile, T) end.
 
 
-git_clone(Uri,Fast,TrunkPath,Rev) when Rev == "head" orelse Rev == "HEAD" orelse Rev == "master" ->
+git_clone(Uri,Fast,TrunkPath,Rev) when Rev == "head" orelse Rev == "HEAD" orelse Rev == "master" orelse Rev == [] ->
     {["git clone ",Fast,Uri," ",TrunkPath],Rev};
     {["git clone ",Fast,Uri," ",TrunkPath],Rev};
 git_clone(Uri,_Fast,TrunkPath,Rev) ->
 git_clone(Uri,_Fast,TrunkPath,Rev) ->
     {["git clone ",Uri," ",TrunkPath," && cd ",TrunkPath," && git checkout \"",Rev,"\"" ],Rev}.
     {["git clone ",Uri," ",TrunkPath," && cd ",TrunkPath," && git checkout \"",Rev,"\"" ],Rev}.