Fix regression introduced in #1946 (#1950)
The change in #1946 introduced a regression such that it did not allow for Node.js zipped actions which contain an index.js but not a package.json. This is a valid configuration and should be supported.
diff --git a/tests/src/actionContainers/NodeJsActionContainerTests.scala b/tests/src/actionContainers/NodeJsActionContainerTests.scala
index c0ac8f1..b43229f 100644
--- a/tests/src/actionContainers/NodeJsActionContainerTests.scala
+++ b/tests/src/actionContainers/NodeJsActionContainerTests.scala
@@ -413,6 +413,36 @@
})
}
+ it should "support zip-encoded npm package actions without a package.json file" in {
+ val srcs = Seq(
+ Seq("index.js") -> """
+ | exports.main = function (args) {
+ | var name = typeof args["name"] === "string" ? args["name"] : "stranger";
+ |
+ | return {
+ | greeting: "Hello " + name + ", from an npm package action without a package.json."
+ | };
+ | }
+ """.stripMargin)
+
+ val code = ZipBuilder.mkBase64Zip(srcs)
+
+ val (out, err) = withNodeJsContainer { c =>
+ c.init(initPayload(code))._1 should be(200)
+
+ val (runCode, runRes) = c.run(runPayload(JsObject()))
+
+ runCode should be(200)
+ runRes.get.fields.get("greeting") shouldBe Some(JsString("Hello stranger, from an npm package action without a package.json."))
+ }
+
+ checkStreams(out, err, {
+ case (o, e) =>
+ o shouldBe empty
+ e shouldBe empty
+ })
+ }
+
it should "fail gracefully on invalid zip files" in {
// Some text-file encoded to base64.
val code = "Q2VjaSBuJ2VzdCBwYXMgdW4gemlwLgo="
@@ -444,7 +474,7 @@
checkStreams(out, err, {
case (o, e) =>
(o + e).toLowerCase should include("error")
- (o + e).toLowerCase should include("package.json must be located at the root of a zipped action")
+ (o + e).toLowerCase should include("zipped actions must contain either package.json or index.js at the root.")
})
}