Default package name to . when not specified

When running tinygo build, and the positional argument for the
package is not specified, default it to "."
This commit is contained in:
Carolyn Van Slyck
2019-06-18 08:22:26 -05:00
committed by Ron Evans
parent ed7c242a09
commit ce9b21a270
+13 -6
View File
@@ -640,8 +640,11 @@ func main() {
usage()
os.Exit(1)
}
if flag.NArg() != 1 {
fmt.Fprintln(os.Stderr, "No package specified.")
pkgName := "."
if flag.NArg() == 1 {
pkgName = flag.Arg(0)
} else if flag.NArg() > 1 {
fmt.Fprintln(os.Stderr, "build only accepts a single positional argument: package name, but multiple were specified")
usage()
os.Exit(1)
}
@@ -649,7 +652,7 @@ func main() {
if target == "" && filepath.Ext(*outpath) == ".wasm" {
target = "wasm"
}
err := Build(flag.Arg(0), *outpath, target, config)
err := Build(pkgName, *outpath, target, config)
handleCompilerError(err)
case "build-builtins":
// Note: this command is only meant to be used while making a release!
@@ -692,11 +695,15 @@ func main() {
err := Run(flag.Arg(0), *target, config)
handleCompilerError(err)
case "test":
pkgRoot := "."
pkgName := "."
if flag.NArg() == 1 {
pkgRoot = flag.Arg(0)
pkgName = flag.Arg(0)
} else if flag.NArg() > 1 {
fmt.Fprintln(os.Stderr, "test only accepts a single positional argument: package name, but multiple were specified")
usage()
os.Exit(1)
}
err := Test(pkgRoot, *target, config)
err := Test(pkgName, *target, config)
handleCompilerError(err)
case "clean":
// remove cache directory