php-src/win32/build/cvsclean.js

121 lines
3.5 KiB
JavaScript
Raw Normal View History

/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
2009-07-14 00:02:34 +08:00
| Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
2006-01-01 20:51:34 +08:00
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
2006-01-01 20:51:34 +08:00
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
2009-07-14 00:02:34 +08:00
| Pierre A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
2009-07-14 00:02:34 +08:00
/* $Id$ */
// Cleans up files that do not belong in the repository
var FSO = WScript.CreateObject("Scripting.FileSystemObject");
2009-07-14 00:02:34 +08:00
var WshShell = WScript.CreateObject("WScript.Shell");
var STDOUT = WScript.StdOut;
2009-07-14 00:02:34 +08:00
/* svn propget svn:ignore dirname */
function find_ignore(dirname)
{
2009-07-14 00:02:34 +08:00
dirname = "" + dirname;
dirname_len = dirname.length;
if (!FSO.FolderExists(dirname) || (dirname_len >= 4 &&
dirname.substring(dirname_len - 4) == ".svn")) {
return;
2009-07-14 00:02:34 +08:00
}
var f = FSO.GetFolder(dirname);
var fc = new Enumerator(f.SubFolders);
2009-07-14 00:02:34 +08:00
for (; !fc.atEnd(); fc.moveNext()) {
2009-07-14 00:02:34 +08:00
find_ignore(fc.item());
}
2009-07-14 00:02:34 +08:00
kill_from_ignore(dirname);
}
2009-07-14 00:02:34 +08:00
/* recursive remove using ignore props style wildcard matching;
* note that FSO.DeleteFolder and FSO.DeleteFile methods both
* accept wildcards, but that they are dangerous to use eg:
* "*.php" will match "*.phpt" */
function rm_r(filename)
{
if (FSO.FolderExists(filename)) {
var fc = new Enumerator(FSO.GetFolder(filename).SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
rm_r(fc.item());
}
fc = new Enumerator(FSO.GetFolder(filename).Files);
for (; !fc.atEnd(); fc.moveNext()) {
FSO.DeleteFile(fc.item(), true);
}
FSO.DeleteFolder(filename, true);
} else if (FSO.FileExists(filename)) {
FSO.DeleteFile(filename, true);
} else {
/* we need to handle wildcards here */
var foldername = FSO.GetParentFolderName(filename);
if (foldername == "")
foldername = ".";
2009-07-14 00:02:34 +08:00
var filename = FSO.GetFileName(filename);
var retext = filename.replace(/\./g, '\\.');
retext = '^' + retext.replace(/\*/g, '.*') + "$";
var re = new RegExp(retext);
var folder = FSO.GetFolder(foldername);
var fc = new Enumerator(folder.SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
var item = FSO.GetFileName(fc.item());
if (item.match(re)) {
rm_r(fc.item());
}
}
var fc = new Enumerator(folder.Files);
for (; !fc.atEnd(); fc.moveNext()) {
item = FSO.GetFileName(fc.item());
if (item.match(re)) {
FSO.DeleteFile(fc.item(), true);
}
}
}
}
2009-07-14 00:02:34 +08:00
function kill_from_ignore(dirname)
{
var l;
2009-07-14 00:02:34 +08:00
var e = WshShell.Exec("svn propget svn:ignore " + dirname);
var re = /^(config\.nice.*)|(\*)$/i;
while (!e.StdOut.atEndOfStream) {
l = e.StdOut.ReadLine();
if (l.length == 0 || re.test(l)) {
continue;
2009-07-14 00:02:34 +08:00
}
rm_r(dirname + l);
}
}
2009-07-14 00:02:34 +08:00
find_ignore(".");