Skip to content

Commit

Permalink
Change all references to std.file in commandline to FQN
Browse files Browse the repository at this point in the history
This makes it more visible where std.file is used, as we want
to reduce the number of places we do I/O, and as we have
two ways to do I/O in Dub.
  • Loading branch information
Geod24 committed Mar 8, 2024
1 parent 30d39f8 commit cdbe4f8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import std.array;
import std.conv;
import std.encoding;
import std.exception;
import std.file;
static import std.file;
import std.getopt;
import std.path : absolutePath, buildNormalizedPath, expandTilde, setExtension;
import std.process : environment, spawnProcess, wait;
Expand Down Expand Up @@ -173,7 +173,7 @@ struct CommandLineHandler

if (options.root_path.empty)
{
options.root_path = getcwd();
options.root_path = std.file.getcwd();
}
else
{
Expand Down Expand Up @@ -281,7 +281,7 @@ unittest {

auto args = new CommandArgs([]);
handler.prepareOptions(args);
assert(handler.options.root_path == getcwd());
assert(handler.options.root_path == std.file.getcwd());
}

/// It can set a custom root_path
Expand Down Expand Up @@ -386,8 +386,6 @@ unittest {
*/
int runDubCommandLine(string[] args)
{
import std.file : tempDir;

static string[] toSinglePackageArgs (string args0, string file, string[] trailing)
{
return [args0, "run", "-q", "--temp-build", "--single", file, "--"] ~ trailing;
Expand Down Expand Up @@ -450,11 +448,11 @@ int runDubCommandLine(string[] args)
// we only consider the case where the file name is the first argument,
// as the shell invocation cannot be controlled.
else if (handler.getCommand(args[1]) is null && !args[1].startsWith("-")) {
if (exists(args[1])) {
if (std.file.exists(args[1])) {
auto path = getTempFile("app", ".d");
copy(args[1], path.toNativeString());
std.file.copy(args[1], path.toNativeString());
args = toSinglePackageArgs(args[0], path.toNativeString(), args[2 .. $]);
} else if (exists(args[1].setExtension(".d"))) {
} else if (std.file.exists(args[1].setExtension(".d"))) {
args = toSinglePackageArgs(args[0], args[1].setExtension(".d"), args[2 .. $]);
}
}
Expand Down Expand Up @@ -2844,7 +2842,7 @@ class DustmiteCommand : PackageBuildCommand {
logInfo("Starting", Color.light_green, "Executing dustmite...");
auto testcmd = appender!string();
testcmd.formattedWrite("%s dustmite --test-package=%s --build=%s --config=%s",
thisExePath, prj.name, this.baseSettings.buildType, this.baseSettings.config);
std.file.thisExePath, prj.name, this.baseSettings.buildType, this.baseSettings.config);

if (m_compilerName.length) testcmd.formattedWrite(" \"--compiler=%s\"", m_compilerName);
if (m_arch.length) testcmd.formattedWrite(" --arch=%s", m_arch);
Expand Down

0 comments on commit cdbe4f8

Please sign in to comment.