From 93da0dbcf7f8e352d152b8c3b8402e432abfabca Mon Sep 17 00:00:00 2001
From: Kevin Mitchell <kevin@infielddesign.com>
Date: Tue, 3 Apr 2018 17:05:27 -0600
Subject: [PATCH 1/3] Adding OpenWhisk sequence support for situations without
 handler

---
 src/types.ts      |  1 +
 src/typescript.ts | 24 +++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/types.ts b/src/types.ts
index 4ad23338..9896cfde 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -25,6 +25,7 @@ export interface ServerlessOptions {
 export interface ServerlessFunction {
   handler: string
   package: ServerlessPackage
+  sequence?: string[]
 }
 
 export interface ServerlessPackage {
diff --git a/src/typescript.ts b/src/typescript.ts
index f18e59b4..8687c78e 100644
--- a/src/typescript.ts
+++ b/src/typescript.ts
@@ -47,6 +47,28 @@ export function extractFileNames(cwd: string, provider: string, functions?: { [k
     }
   }
 
+  // With OpenWhisk not all functions may actually have a code entrypoint - some may be "meta" functions / actions,
+  // most notably the "sequence" functions that are combinations of other functions. These may not actually
+  // have any code associated with them, aka no handler
+  if (provider === "openwhisk") {
+    return (
+      _.values(functions)
+        //If this function is a sequence and doesn't have a handler defined we'll filter these out
+        .filter(fn => {
+          if (fn.sequence && !fn.handler) {
+            return null;
+          }
+          return true;
+        })
+        .map(fn => {
+          const fnName = _.last(fn.handler.split("."));
+          const fnNameLastAppearanceIndex = fn.handler.lastIndexOf(fnName);
+          // replace only last instance to allow the same name for file and handler
+          return fn.handler.substring(0, fnNameLastAppearanceIndex) + "ts";
+        })
+    );
+  }
+
   return _.values(functions)
     .map(fn => fn.handler)
     .map(h => {
@@ -69,7 +91,7 @@ export async function run(fileNames: string[], options: ts.CompilerOptions): Pro
     if (!diagnostic.file) {
       console.log(diagnostic)
     }
-    const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start)
+    const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start)
     const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')
     console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)
   })

From afaa04e593faae3ee121908620eab21024b8d66d Mon Sep 17 00:00:00 2001
From: Kevin Mitchell <kevin@infielddesign.com>
Date: Sun, 8 Apr 2018 12:51:52 -0500
Subject: [PATCH 2/3] Fix filter response to return false from filter instead
 of null

---
 src/typescript.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/typescript.ts b/src/typescript.ts
index 8687c78e..e1c643c8 100644
--- a/src/typescript.ts
+++ b/src/typescript.ts
@@ -56,7 +56,7 @@ export function extractFileNames(cwd: string, provider: string, functions?: { [k
         //If this function is a sequence and doesn't have a handler defined we'll filter these out
         .filter(fn => {
           if (fn.sequence && !fn.handler) {
-            return null;
+            return false;
           }
           return true;
         })

From e77f13843db7aaeb0743c08f7728a49edcb132ff Mon Sep 17 00:00:00 2001
From: Kevin Mitchell <kevin@infielddesign.com>
Date: Sun, 8 Apr 2018 17:28:19 -0500
Subject: [PATCH 3/3] Fix linting issues

---
 src/typescript.ts | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/typescript.ts b/src/typescript.ts
index e1c643c8..6a0cb5d7 100644
--- a/src/typescript.ts
+++ b/src/typescript.ts
@@ -50,23 +50,23 @@ export function extractFileNames(cwd: string, provider: string, functions?: { [k
   // With OpenWhisk not all functions may actually have a code entrypoint - some may be "meta" functions / actions,
   // most notably the "sequence" functions that are combinations of other functions. These may not actually
   // have any code associated with them, aka no handler
-  if (provider === "openwhisk") {
+  if (provider === 'openwhisk') {
     return (
       _.values(functions)
-        //If this function is a sequence and doesn't have a handler defined we'll filter these out
+        // If this function is a sequence and doesn't have a handler defined we'll filter these out
         .filter(fn => {
           if (fn.sequence && !fn.handler) {
-            return false;
+            return false
           }
-          return true;
+          return true
         })
         .map(fn => {
-          const fnName = _.last(fn.handler.split("."));
-          const fnNameLastAppearanceIndex = fn.handler.lastIndexOf(fnName);
+          const fnName = _.last(fn.handler.split('.'))
+          const fnNameLastAppearanceIndex = fn.handler.lastIndexOf(fnName)
           // replace only last instance to allow the same name for file and handler
-          return fn.handler.substring(0, fnNameLastAppearanceIndex) + "ts";
+          return fn.handler.substring(0, fnNameLastAppearanceIndex) + 'ts'
         })
-    );
+    )
   }
 
   return _.values(functions)