Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8a19fd7

Browse files
Fixing node.js and npm PATH problem, loading automatically the PATH from the user's shell env.
1 parentbf6b3fc commit8a19fd7

File tree

5 files changed

+237
-4
lines changed

5 files changed

+237
-4
lines changed

‎_generated_2018_01_25_at_02_31_42.py‎renamed to ‎_generated_2018_01_25_at_15_56_26.py‎

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
importos,sys,imp,platform,json,traceback,threading,urllib,shutil,re,time
33
fromshutilimportcopyfile
44
fromthreadingimportTimer
5+
fromosimportenviron
6+
fromsubprocessimportPopen,PIPE
57

6-
PLUGIN_VERSION="0.13.15"
8+
PLUGIN_VERSION="0.13.16"
79

810
PACKAGE_PATH=os.path.abspath(os.path.dirname(__file__))
911
PACKAGE_NAME=os.path.basename(PACKAGE_PATH)
@@ -5984,10 +5986,79 @@ def start():
59845986

59855987
mainPlugin.init()
59865988

5989+
##
5990+
## start - Fix Mac Path plugin code with some fixes
5991+
##
5992+
5993+
fixPathSettings=None
5994+
fixPathOriginalEnv= {}
5995+
5996+
defgetSysPath():
5997+
command=""
5998+
ifplatform.system()=="Darwin":
5999+
command="TERM=ansi CLICOLOR=\"\" SUBLIME=1 /usr/bin/login -fqpl $USER $SHELL -l -c 'TERM=ansi CLICOLOR=\"\" SUBLIME=1 printf\"%s\"\"$PATH\"'"
6000+
elifplatform.system()=="Linux":
6001+
command="TERM=ansi CLICOLOR=\"\" SUBLIME=1 $SHELL --login -c 'TERM=ansi CLICOLOR=\"\" printf\"%s\" $PATH'"
6002+
else:
6003+
return""
6004+
6005+
# Execute command with original environ. Otherwise, our changes to the PATH propogate down to
6006+
# the shell we spawn, which re-adds the system path & returns it, leading to duplicate values.
6007+
sysPath=Popen(command,stdout=PIPE,shell=True,env=fixPathOriginalEnv).stdout.read()
6008+
6009+
sysPathString=sysPath.decode("utf-8")
6010+
# Remove ANSI control characters (see: http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed )
6011+
sysPathString=re.sub(r'\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]','',sysPathString)
6012+
sysPathString=sysPathString.strip().rstrip(':')
6013+
6014+
# Decode the byte array into a string, remove trailing whitespace, remove trailing ':'
6015+
returnsysPathString
6016+
6017+
deffixPath():
6018+
currSysPath=getSysPath()
6019+
# Basic sanity check to make sure our new path is not empty
6020+
iflen(currSysPath)<1:
6021+
returnFalse
6022+
6023+
environ['PATH']=currSysPath
6024+
6025+
forpathIteminfixPathSettings.get("additional_path_items", []):
6026+
environ['PATH']=pathItem+':'+environ['PATH']
6027+
6028+
returnTrue
6029+
6030+
6031+
defplugin_unloaded():
6032+
# When we unload, reset PATH to original value. Otherwise, reloads of this plugin will cause
6033+
# the PATH to be duplicated.
6034+
environ['PATH']=fixPathOriginalEnv['PATH']
6035+
6036+
globalfixPathSettings
6037+
fixPathSettings.clear_on_change('fixpath-reload')
6038+
6039+
##
6040+
## end - Fix Mac Path plugin code
6041+
##
6042+
59876043
defplugin_loaded():
59886044

59896045
ifint(sublime.version())>=3124 :
6046+
6047+
ifplatform.system()=="Darwin"orplatform.system()=="Linux":
6048+
globalfixPathSettings
6049+
fixPathSettings=sublime.load_settings("Preferences.sublime-settings")
6050+
fixPathSettings.clear_on_change('fixpath-reload')
6051+
fixPathSettings.add_on_change('fixpath-reload',fixPath)
6052+
6053+
# Save the original environ (particularly the original PATH) to restore later
6054+
globalfixPathOriginalEnv
6055+
forkeyinenviron:
6056+
fixPathOriginalEnv[key]=environ[key]
6057+
6058+
fixPath()
6059+
59906060
sublime.set_timeout_async(start,1000)
6061+
59916062
else:
59926063
response=sublime.yes_no_cancel_dialog("JavaScript Enhancements plugin requires Sublime Text 3 (build 3124 or newer). Your build is: "+sublime.version()+". Do you want open the download page?","Yes, open it","No")
59936064
ifresponse==sublime.DIALOG_YES:

‎changelog/0.13.16.txt‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
v0.13.16
2+
3+
## Fixes
4+
5+
- Fixing node.js and npm PATH problem, loading automatically the PATH from the user's shell env.
6+
7+
8+
9+
=================================================================
10+
** THIS PLUGIN IS IN BETA! Thanks for your support in advance! **
11+
=================================================================
12+
13+
If you like it, remember to star it ⭐ on GitHub: https://github.com/pichillilorenzo/JavaScriptEnhancements
14+
15+
** USAGE **
16+
===========
17+
18+
See how it works on the Wiki: 👉👉 https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki 👈👈
19+
20+
21+
** WHAT IS THIS? **
22+
===================
23+
24+
This plugin uses Flow (javascript static type checker from Facebook) under the hood.
25+
26+
It offers better javascript autocomplete and a lot of features about creating,
27+
developing and managing javascript projects, such as:
28+
29+
- Cordova projects (run cordova emulate, build, compile, serve, etc. directly from Sublime Text!)
30+
- Ionic v1 and v2 projects (same as Cordova projects!)
31+
- Angular v1 and v2 projects
32+
- React projects (only about the creation at this moment)
33+
- React Native projects (only about the creation at this moment. I will add also NativeScript support)
34+
- Express projects (only about the creation at this moment)
35+
- Yeoman generators
36+
- Local bookmarks project
37+
- JavaScript real-time errors
38+
- etc.
39+
40+
You could use it also in existing projects (see the Wiki - https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki/Using-it-with-an-existing-project)!
41+
42+
It turns Sublime Text into a JavaScript IDE like!
43+
44+
This project is based on my other Sublime Text plugin JavaScript Completions (https://github.com/pichillilorenzo/JavaScript-Completions)
45+
46+
** NOTE **
47+
If you want use this plugin, you may want uninstall/disable the JavaScript Completions plugin, if installed.
48+
49+
** OS SUPPORTED NOW **
50+
======================
51+
52+
👉 Linux (64-bit)
53+
👉 Mac OS X
54+
👉 Windows (64-bit): released without the use of TerminalView plugin. For each feature (like also creating a project) will be used the cmd.exe shell (so during the creation of a project don't close it until it finishes!). Unfortunately the TerminalView plugin supports only Linux-based OS 😞. Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
55+
56+
❗❗ Dependencies ❗❗
57+
=======================
58+
59+
In order to work properly, this plugin has some dependencies:
60+
61+
👉 Sublime Text 3 (build 3124 or newer)
62+
👉 Node.js and npm (https://nodejs.org or nvm (https://github.com/creationix/nvm))
63+
👉 TerminalView (only for Linux and Mac OS X) sublime text plugin (https://github.com/Wramberg/TerminalView)
64+
65+
Not required, but useful for typescript files (Flow wont work on this type of files):
66+
67+
👉 TypeScript sublime text plugin (https://github.com/Microsoft/TypeScript-Sublime-Plugin)
68+
69+
** Flow Requirements **
70+
=======================
71+
72+
It use [Flow](https://github.com/facebook/flow) for type checking and auto-completions.
73+
74+
👉 Mac OS X
75+
👉 Linux (64-bit)
76+
👉 Windows (64-bit)
77+
78+
Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com
79+
80+
** Donation **
81+
==============
82+
83+
If this project help you reduce time to develop and also you like it, please support it with a donation 😄👍. Thanks!
84+
85+
Open Collective: https://opencollective.com/javascriptenhancements/donate
86+
PayPal: https://www.paypal.me/LorenzoPichilli
87+
88+
Thanks anyway for your support! 😄😄
89+
90+
MIT License

‎helper/can_i_use/can_i_use_data.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎make/_init.py‎

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
importos,sys,imp,platform,json,traceback,threading,urllib,shutil,re,time
33
fromshutilimportcopyfile
44
fromthreadingimportTimer
5+
fromosimportenviron
6+
fromsubprocessimportPopen,PIPE
57

6-
PLUGIN_VERSION="0.13.15"
8+
PLUGIN_VERSION="0.13.16"
79

810
PACKAGE_PATH=os.path.abspath(os.path.dirname(__file__))
911
PACKAGE_NAME=os.path.basename(PACKAGE_PATH)
@@ -185,10 +187,79 @@ def start():
185187

186188
mainPlugin.init()
187189

190+
##
191+
## start - Fix Mac Path plugin code with some fixes
192+
##
193+
194+
fixPathSettings=None
195+
fixPathOriginalEnv= {}
196+
197+
defgetSysPath():
198+
command=""
199+
ifplatform.system()=="Darwin":
200+
command="TERM=ansi CLICOLOR=\"\" SUBLIME=1 /usr/bin/login -fqpl $USER $SHELL -l -c 'TERM=ansi CLICOLOR=\"\" SUBLIME=1 printf\"%s\"\"$PATH\"'"
201+
elifplatform.system()=="Linux":
202+
command="TERM=ansi CLICOLOR=\"\" SUBLIME=1 $SHELL --login -c 'TERM=ansi CLICOLOR=\"\" printf\"%s\" $PATH'"
203+
else:
204+
return""
205+
206+
# Execute command with original environ. Otherwise, our changes to the PATH propogate down to
207+
# the shell we spawn, which re-adds the system path & returns it, leading to duplicate values.
208+
sysPath=Popen(command,stdout=PIPE,shell=True,env=fixPathOriginalEnv).stdout.read()
209+
210+
sysPathString=sysPath.decode("utf-8")
211+
# Remove ANSI control characters (see: http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed )
212+
sysPathString=re.sub(r'\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]','',sysPathString)
213+
sysPathString=sysPathString.strip().rstrip(':')
214+
215+
# Decode the byte array into a string, remove trailing whitespace, remove trailing ':'
216+
returnsysPathString
217+
218+
deffixPath():
219+
currSysPath=getSysPath()
220+
# Basic sanity check to make sure our new path is not empty
221+
iflen(currSysPath)<1:
222+
returnFalse
223+
224+
environ['PATH']=currSysPath
225+
226+
forpathIteminfixPathSettings.get("additional_path_items", []):
227+
environ['PATH']=pathItem+':'+environ['PATH']
228+
229+
returnTrue
230+
231+
232+
defplugin_unloaded():
233+
# When we unload, reset PATH to original value. Otherwise, reloads of this plugin will cause
234+
# the PATH to be duplicated.
235+
environ['PATH']=fixPathOriginalEnv['PATH']
236+
237+
globalfixPathSettings
238+
fixPathSettings.clear_on_change('fixpath-reload')
239+
240+
##
241+
## end - Fix Mac Path plugin code
242+
##
243+
188244
defplugin_loaded():
189245

190246
ifint(sublime.version())>=3124 :
247+
248+
ifplatform.system()=="Darwin"orplatform.system()=="Linux":
249+
globalfixPathSettings
250+
fixPathSettings=sublime.load_settings("Preferences.sublime-settings")
251+
fixPathSettings.clear_on_change('fixpath-reload')
252+
fixPathSettings.add_on_change('fixpath-reload',fixPath)
253+
254+
# Save the original environ (particularly the original PATH) to restore later
255+
globalfixPathOriginalEnv
256+
forkeyinenviron:
257+
fixPathOriginalEnv[key]=environ[key]
258+
259+
fixPath()
260+
191261
sublime.set_timeout_async(start,1000)
262+
192263
else:
193264
response=sublime.yes_no_cancel_dialog("JavaScript Enhancements plugin requires Sublime Text 3 (build 3124 or newer). Your build is: "+sublime.version()+". Do you want open the download page?","Yes, open it","No")
194265
ifresponse==sublime.DIALOG_YES:

‎messages.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"0.13.12":"changelog/0.13.12.txt",
1616
"0.13.13":"changelog/0.13.13.txt",
1717
"0.13.14":"changelog/0.13.14.txt",
18-
"0.13.15":"changelog/0.13.15.txt"
18+
"0.13.15":"changelog/0.13.15.txt",
19+
"0.13.16":"changelog/0.13.16.txt"
1920
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp