|
@@ -1,18 +1,18 @@ discard block |
|
|
block discarded – undo |
|
1
|
1
|
<?php |
|
2
|
2
|
|
|
3
|
3
|
const NODE_MODULES_FOLDER_NAME = 'node_modules'; |
|
4
|
|
-const PATH_TO_NODE_MODULES = 'tests' . DIRECTORY_SEPARATOR . 'Application' . DIRECTORY_SEPARATOR . 'node_modules'; |
|
|
4
|
+const PATH_TO_NODE_MODULES = 'tests'.DIRECTORY_SEPARATOR.'Application'.DIRECTORY_SEPARATOR.'node_modules'; |
|
5
|
5
|
|
|
6
|
6
|
/* cannot use `file_exists` or `stat` as gives false on symlinks if target path does not exist yet */ |
|
7
|
7
|
if (@lstat(NODE_MODULES_FOLDER_NAME)) |
|
8
|
8
|
{ |
|
9
|
9
|
if (is_link(NODE_MODULES_FOLDER_NAME) || is_dir(NODE_MODULES_FOLDER_NAME)) { |
|
10
|
|
- echo '> `' . NODE_MODULES_FOLDER_NAME . '` already exists as a link or folder, keeping existing as may be intentional.' . PHP_EOL; |
|
|
10
|
+ echo '> `'.NODE_MODULES_FOLDER_NAME.'` already exists as a link or folder, keeping existing as may be intentional.'.PHP_EOL; |
|
11
|
11
|
exit(0); |
|
12
|
12
|
} else { |
|
13
|
|
- echo '> Invalid symlink `' . NODE_MODULES_FOLDER_NAME . '` detected, recreating...' . PHP_EOL; |
|
|
13
|
+ echo '> Invalid symlink `'.NODE_MODULES_FOLDER_NAME.'` detected, recreating...'.PHP_EOL; |
|
14
|
14
|
if (!@unlink(NODE_MODULES_FOLDER_NAME)) { |
|
15
|
|
- echo '> Could not delete file `' . NODE_MODULES_FOLDER_NAME . '`.' . PHP_EOL; |
|
|
15
|
+ echo '> Could not delete file `'.NODE_MODULES_FOLDER_NAME.'`.'.PHP_EOL; |
|
16
|
16
|
exit(1); |
|
17
|
17
|
} |
|
18
|
18
|
} |
|
@@ -24,12 +24,12 @@ discard block |
|
|
block discarded – undo |
|
24
|
24
|
/* if case it has failed, but OS is Windows... */ |
|
25
|
25
|
if (!$success && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
26
|
26
|
/* ...then try a different approach which does not require elevated permissions and folder to exist */ |
|
27
|
|
- echo '> This system is running Windows, creation of links requires elevated privileges,' . PHP_EOL; |
|
28
|
|
- echo '> and target path to exist. Fallback to NTFS Junction:' . PHP_EOL; |
|
|
27
|
+ echo '> This system is running Windows, creation of links requires elevated privileges,'.PHP_EOL; |
|
|
28
|
+ echo '> and target path to exist. Fallback to NTFS Junction:'.PHP_EOL; |
|
29
|
29
|
exec(sprintf('mklink /J %s %s 2> NUL', NODE_MODULES_FOLDER_NAME, PATH_TO_NODE_MODULES), $output, $returnCode); |
|
30
|
30
|
$success = $returnCode === 0; |
|
31
|
31
|
if (!$success) { |
|
32
|
|
- echo '> Failed o create the required symlink' . PHP_EOL; |
|
|
32
|
+ echo '> Failed o create the required symlink'.PHP_EOL; |
|
33
|
33
|
exit(2); |
|
34
|
34
|
} |
|
35
|
35
|
} |
|
@@ -37,9 +37,9 @@ discard block |
|
|
block discarded – undo |
|
37
|
37
|
$path = @readlink(NODE_MODULES_FOLDER_NAME); |
|
38
|
38
|
/* check if link points to the intended directory */ |
|
39
|
39
|
if ($path && realpath($path) === realpath(PATH_TO_NODE_MODULES)) { |
|
40
|
|
- echo '> Successfully created the symlink.' . PHP_EOL; |
|
|
40
|
+ echo '> Successfully created the symlink.'.PHP_EOL; |
|
41
|
41
|
exit(0); |
|
42
|
42
|
} |
|
43
|
43
|
|
|
44
|
|
-echo '> Failed to create the symlink to `' . NODE_MODULES_FOLDER_NAME . '`.' . PHP_EOL; |
|
|
44
|
+echo '> Failed to create the symlink to `'.NODE_MODULES_FOLDER_NAME.'`.'.PHP_EOL; |
|
45
|
45
|
exit(3); |