diff --git a/src/cli.ts b/src/cli.ts index e3c6b87..f510599 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -138,10 +138,6 @@ import utils = require('./lib/utils'); console.log("Loading ESCMAScript modules not available on NodeJS < 12.0.0."); process.exit(1); } - if (program.watch) { - console.log("Watch mode not supported for ECMAScript lambda modules."); - process.exit(1); - } } var event = function(){ if(program.watch) return null; diff --git a/test/functs/test-func-esm-echo.mjs b/test/functs/test-func-esm-echo.mjs new file mode 100644 index 0000000..a9ad45f --- /dev/null +++ b/test/functs/test-func-esm-echo.mjs @@ -0,0 +1,3 @@ +export async function handler(event, context) { + context.succeed(event); +} diff --git a/test/test.js b/test/test.js index c4103d0..1e2c351 100644 --- a/test/test.js +++ b/test/test.js @@ -590,14 +590,6 @@ describe("- Testing cli.js", function () { assert.equal(r.status, 1); console.log(r.output); }); - - it("should fail: esm with unsupported watch mode", function () { - var command = get_shell("node ../build/cli.js -l ./functs/test-func-esm.mjs --esm --watch"); - var r = spawnSync(command[0], command[1]); - process_outputs(r); - assert.equal(r.status, 1); - console.log(r.output); - }) }); describe("* Environment test run", function () { @@ -673,6 +665,19 @@ describe("- Testing cli.js", function () { cb ); }); + it("test watch with esm", function (cb) { + var command = get_shell("node ../build/cli.js -l ./functs/test-func-esm-echo.mjs --watch --esm"); + var r = spawnAsync(command[0], command[1]); + doRequestWhenReady(r, + { + "hey": "data", + }, + (result) => { + assert.deepEqual(result["body"], {"hey": "data"}); + }, + cb + ); + }); }); }