Fix codemirror re-installation

When re-installing a dependency with 'map' entries containing * character
these dest folders were not properly cleaned up before moving new files
to them. It's because path with * does not work in is_dir().
pull/5702/head
Aleksander Machniak 7 years ago
parent 7347c22af8
commit 9eefa47e45

@ -213,8 +213,12 @@ function extract_zipfile($package, $srcfile)
$extract = $CACHEDIR . '/' . $package['lib'] . '-extract';
exec(sprintf('%s -o %s -d %s', $UNZIP, escapeshellarg($srcfile), $extract), $out, $retval);
// get the root folder of the extracted package
$extract_tree = glob("$extract/*", GLOB_ONLYDIR);
$sourcedir = $extract_tree[0];
foreach ($package['map'] as $src => $dest) {
echo "Installing files $extract/$src into $destdir/$dest\n";
echo "Installing files $sourcedir/$src into $destdir/$dest\n";
// make sure the destination's parent directory exists
if (strpos($dest, '/') !== false) {
@ -225,11 +229,11 @@ function extract_zipfile($package, $srcfile)
}
// avoid copying source directory as a child into destination
if (is_dir($extract . '/' . $src) && is_dir($destdir . '/' . $dest)) {
if (is_dir($sourcedir . '/' . $src) && is_dir($destdir . '/' . $dest)) {
exec(sprintf('rm -rf %s/%s', $destdir, $dest));
}
exec(sprintf('mv -f %s/%s %s/%s', $extract, $src, $destdir, $dest), $out, $retval);
exec(sprintf('mv -f %s/%s %s/%s', $sourcedir, $src, $destdir, $dest), $out, $retval);
if ($retval !== 0) {
echo "ERROR: Failed to move $src into $destdir/$dest; " . join('; ' . $out) . "\n";
}

@ -43,7 +43,7 @@
"copyright": "Copyright (c) 1999-2015 Ephox Corp. All rights reserved",
"rm": "program/js/tinymce",
"map": {
"tinymce/js/tinymce": "tinymce"
"js/tinymce": "tinymce"
},
"omit": [
"tinymce/license.txt",
@ -78,9 +78,9 @@
"sha1": "3b767c2e3acd6796e54ed19ed2ac0755fcf87984",
"license": "MIT",
"map": {
"*/lib": "lib",
"*/addon/selection": "addon/selection",
"*/mode/sieve": "mode/sieve"
"lib": "lib",
"addon/selection": "addon/selection",
"mode/sieve": "mode/sieve"
}
}
]

Loading…
Cancel
Save