@@ -27,7 +27,7 @@ protected function getInstallPath()
27
27
$ currentUser = $ this ->system ->getCurrentUser ();
28
28
29
29
if ('Administrator ' === $ currentUser ) {
30
- return ' C:\ProgramData \jupyter-php ' ;
30
+ return $ this -> getProgramDataPath () . ' \jupyter-php ' ;
31
31
} else {
32
32
return $ this ->system ->getCurrentUserHome () . '\.jupyter-php ' ;
33
33
}
@@ -48,8 +48,8 @@ protected function installKernel()
48
48
$ currentUser = $ this ->system ->getCurrentUser ();
49
49
50
50
$ kernelSpecPath = ('Administrator ' === $ currentUser ) ?
51
- ' C:\ProgramData \jupyter\kernels\jupyter-php ' :
52
- $ this ->system -> getCurrentUserHome () . '\AppData\Roaming \jupyter\kernels\jupyter-php ' ;
51
+ $ this -> getProgramDataPath () . ' \jupyter\kernels\jupyter-php ' :
52
+ $ this ->getAppDataPath () . '\jupyter\kernels\jupyter-php ' ;
53
53
54
54
$ this ->system ->ensurePath ($ kernelSpecPath );
55
55
file_put_contents ($ kernelSpecPath . '\kernel.json ' , $ kernelDef );
@@ -65,12 +65,30 @@ protected function executeSilentComposerCommand($installPath)
65
65
66
66
exec (
67
67
$ this ->composerCmd . ' --prefer-dist --no-interaction --no-progress --working-dir=" ' .
68
- $ installPath . '" create-project litipk/jupyter-php=dev-master pkgs > nul 2>&1 ' ,
68
+ $ installPath . '" create-project litipk/jupyter-php=dev-master ' . ' pkgs > nul 2>&1 ' ,
69
69
70
70
$ composerOutputLines ,
71
71
$ composerStatus
72
72
);
73
73
74
74
return $ composerStatus ;
75
75
}
76
+
77
+ private function getProgramDataPath ()
78
+ {
79
+ if (function_exists ('getenv ' ) && false !== getenv ('PROGRAMDATA ' )) {
80
+ return getenv ('PROGRAMDATA ' );
81
+ } else {
82
+ throw new \RuntimeException ('Unable to obtain the program data directory. ' );
83
+ }
84
+ }
85
+
86
+ private function getAppDataPath ()
87
+ {
88
+ if (function_exists ('getenv ' ) && false !== getenv ('APPDATA ' )) {
89
+ return getenv ('APPDATA ' );
90
+ } else {
91
+ throw new \RuntimeException ('Unable to obtain the app data directory. ' );
92
+ }
93
+ }
76
94
}
0 commit comments