From 9c279164c44c6af87716c7978ba70f66e6f8862e Mon Sep 17 00:00:00 2001 From: DamianEdwards Date: Thu, 6 Nov 2014 13:32:22 -0800 Subject: [PATCH] Updated the grunt target to delete node_modules directory afterward - It shelss out to "robocopy" tool as that is safe for long paths - Doing this to work around the issue with KRE compile failing when long paths are present in the project folder --- build/_k-standard-goals.shade | 8 +++++++- build/_robocopy-delete.shade | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 build/_robocopy-delete.shade diff --git a/build/_k-standard-goals.shade b/build/_k-standard-goals.shade index 93a1b1e54d..5209891176 100644 --- a/build/_k-standard-goals.shade +++ b/build/_k-standard-goals.shade @@ -106,7 +106,13 @@ default Configuration='${E("Configuration")}' -// Find all dirs that contain a gruntfile.js file var gruntDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "gruntfile.js")}' grunt each='var gruntDir in gruntDirs' - + -CallTarget("clean-npm-modules"); + +#clean-npm-modules if='!IsMono' + -// Find all dirs that contain a package.json file + var npmDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json").Select(d => Path.Combine(d, "node_modules"))}' + robocopy-delete dir='${npmDir}' each='var npmDir in npmDirs' + #stylecop stylecop-setup stylecop-run each='var projectFile in Files.Include("src/**/project.json")' diff --git a/build/_robocopy-delete.shade b/build/_robocopy-delete.shade new file mode 100644 index 0000000000..0a351e1433 --- /dev/null +++ b/build/_robocopy-delete.shade @@ -0,0 +1,29 @@ +-// Deletes a directory using robocopy such that long paths aren't an issue +default parentDir = '${Directory.GetParent(dir).FullName}' +default tempDir = '${Path.Combine(parentDir, "__emp_dir")}' +default logFile = '${Path.Combine(parentDir, "robocopy-log.txt")}' + +exec program='cmd' commandline='/C mkdir ${tempDir}' + +@{ + var robocopyProcessStartInfo = new ProcessStartInfo { + UseShellExecute = false, + WorkingDirectory = dir, + FileName = "cmd", + Arguments = "/C robocopy " + tempDir + " " + dir + " /PURGE /NS /NC /NP /NFL /NDL /NJH /NJS /LOG:" + logFile, + }; + + var robocopyProcess = Process.Start(robocopyProcessStartInfo); + robocopyProcess.WaitForExit(); + + // Robocopy encodes results as a bitmap in the return code, see http://ss64.com/nt/robocopy-exit.html + if (robocopyProcess.ExitCode >= 16) + { + throw new Exception(string.Format("Error {0} attempting to delete {1}, see {2} for more details", robocopyProcess.ExitCode, dir, logFile)); + } +} +-//exec program='cmd' commandline='/C robocopy ${tempDir} ${dir} /PURGE /NS /NC /NP /NFL /NDL /NJH /NJS /LOG:${logFile}' + +exec program='cmd' commandline='/C rmdir ${tempDir}' +exec program='cmd' commandline='/C rmdir ${dir}' +exec program='cmd' commandline='/C del ${logFile}' \ No newline at end of file