Created
July 2, 2017 16:42
-
-
Save scorredoira/f0a76dbf3a25cf438365d51ff864a065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ------------------------------------------------------------------ * | |
* Recursively enable/disable git repos | |
* Poor man's submodules | |
* ------------------------------------------------------------------ | |
*/ | |
export function main(enabled: string) { | |
let b = convert.toBool(enabled); | |
processDir(".", b, true, os.fileSystem) | |
} | |
function processDir(dir: string, enabled: boolean, isTopDir: boolean, fs: io.FileSystem) { | |
for (let fi of fs.readDir(dir)) { | |
if (fi.isDir) { | |
switch (fi.name) { | |
case ".git": | |
if (isTopDir) { | |
continue; // don't process the top .git | |
} | |
if (!enabled) { | |
fs.rename(filepath.join(dir, ".git"), filepath.join(dir, ".git_disabled")) | |
} | |
break; | |
case ".git_disabled": | |
if (isTopDir) { | |
continue; // don't process the top .git | |
} | |
if (enabled) { | |
fs.rename(filepath.join(dir, ".git_disabled"), filepath.join(dir, ".git")) | |
} | |
break; | |
default: | |
processDir(filepath.join(dir, fi.name), enabled, false, fs) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment