From 6d3168e2e18ca0335b0922c3085588ce837910c3 Mon Sep 17 00:00:00 2001 From: brianary Date: Sat, 2 Aug 2014 10:21:41 -0700 Subject: [PATCH] Add pushd/popd to FileUtils Adds familiar pushd and popd commands to better support recursive directory navigation. --- src/app/FakeLib/FileUtils.fs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/FakeLib/FileUtils.fs b/src/app/FakeLib/FileUtils.fs index 424722f051b..24010437178 100644 --- a/src/app/FakeLib/FileUtils.fs +++ b/src/app/FakeLib/FileUtils.fs @@ -37,6 +37,18 @@ let cd path = chdir path /// Gets working directory let pwd = Directory.GetCurrentDirectory +/// The stack of directories operated on by pushd and popd +let dirStack = new System.Collections.Generic.Stack() + +/// Store the current directory in the directory stack before changing to a new one +let pushd path = + dirStack.Push(pwd()) + cd path + +/// Restore the previous directory stored in the stack +let popd () = + cd <| dirStack.Pop() + /// Like "mv" in a shell. Moves/renames a file /// The source /// The destination