diff --git a/CHANGELOG.md b/CHANGELOG.md index e6763e1..cf0e478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,13 +10,8 @@ - Dub will then try to get the latest version number for each of these dependencies from code.dlang.org and automatically add them to the dependencies section of dub.json. - If it cant find the dependant package name, it will ignore it, - Current functionality is preserved whereby project type can be determined by using [vibe.d, deimos or minimal] after package name. (So example above would be dub init myProj vibe.d logger vibe-d gfm). -<<<<<<< HEAD - Preferrable to use --type however, as this should be removed for next version. -======= - - Preferrable to use --type however, as this should be removed for next version. - ->>>>>>> origin/init-with-dependencies v0.9.22 - 2014-09-22 -------------------- diff --git a/source/dub/commandline.d b/source/dub/commandline.d index a2347e1..6571982 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -366,18 +366,15 @@ string m_defaultConfig; bool m_nodeps; bool m_forceRemove = false; - bool m_disableBuildOption = false; } override void prepare(scope CommandArgs args) { - if (!m_disableBuildOption) { - args.getopt("b|build", &m_buildType, [ - "Specifies the type of build to perform. Note that setting the DFLAGS environment variable will override the build type with custom flags.", - "Possible names:", - " debug (default), plain, release, release-nobounds, unittest, profile, docs, ddox, cov, unittest-cov and custom types" - ]); - } + args.getopt("b|build", &m_buildType, [ + "Specifies the type of build to perform. Note that setting the DFLAGS environment variable will override the build type with custom flags.", + "Possible names:", + " debug (default), plain, release, release-nobounds, unittest, profile, docs, ddox, cov, unittest-cov and custom types" + ]); args.getopt("c|config", &m_buildConfig, [ "Builds the specified configuration. Configurations can be defined in dub.json" ]); @@ -680,7 +677,6 @@ this.acceptsAppArgs = true; m_buildType = "unittest"; - m_disableBuildOption = true; } override void prepare(scope CommandArgs args) diff --git a/source/dub/dub.d b/source/dub/dub.d index 46060ac..4d46021 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -755,6 +755,10 @@ */ string getModuleNameFromContent(string content) { import std.regex; + import std.string; + + content = content.strip; + if (!content.length) return null; static bool regex_initialized = false; static Regex!char comments_pattern, module_pattern; @@ -766,7 +770,10 @@ } content = replaceAll(content, comments_pattern, ""); - string moduleName = matchFirst(content, module_pattern).front; + auto result = matchFirst(content, module_pattern); + + string moduleName; + if(!result.empty) moduleName = result.front; if (moduleName.length >= 7) moduleName = moduleName[7..$-1]; @@ -774,9 +781,12 @@ } unittest { - import std.stdio; + //test empty string + string name = getModuleNameFromContent(""); + assert(name == "", "can't get module name from empty string"); + //test simple name - string name = getModuleNameFromContent("module myPackage.myModule;"); + name = getModuleNameFromContent("module myPackage.myModule;"); assert(name == "myPackage.myModule", "can't parse module name"); //test if it can ignore module inside comments @@ -799,6 +809,7 @@ string getModuleNameFromFile(string filePath) { string fileContent = filePath.readText; + logDiagnostic("Get module name from path: " ~ filePath); return getModuleNameFromContent(fileContent); } diff --git a/source/dub/internal/vibecompat/core/file.d b/source/dub/internal/vibecompat/core/file.d index 7ac4008..0e004dd 100644 --- a/source/dub/internal/vibecompat/core/file.d +++ b/source/dub/internal/vibecompat/core/file.d @@ -12,7 +12,7 @@ import dub.internal.vibecompat.core.log; import std.conv; -import std.c.stdio; +import core.stdc.stdio; import std.datetime; import std.exception; import std.file; diff --git a/source/dub/project.d b/source/dub/project.d index c6f5abe..ee2cc78 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -921,6 +921,7 @@ auto file = openFile(path, FileMode.CreateTrunc); scope(exit) file.close(); file.writePrettyJsonString(json); + file.put('\n'); m_dirty = false; } diff --git a/source/dub/recipe/json.d b/source/dub/recipe/json.d index bfe010b..1e5e013 100644 --- a/source/dub/recipe/json.d +++ b/source/dub/recipe/json.d @@ -13,8 +13,7 @@ import dub.internal.vibecompat.data.json; -import std.algorithm : canFind; -import std.array : startsWith; +import std.algorithm : canFind, startsWith; import std.conv : to; import std.exception : enforce; import std.range; diff --git a/source/dub/recipe/packagerecipe.d b/source/dub/recipe/packagerecipe.d index 4c6191c..dad1220 100644 --- a/source/dub/recipe/packagerecipe.d +++ b/source/dub/recipe/packagerecipe.d @@ -79,7 +79,7 @@ @property const(Dependency)[string] dependencies() const { - const(Dependency)[string] ret; + Dependency[string] ret; foreach (n, d; this.buildSettings.dependencies) ret[n] = d; foreach (ref c; configurations)