Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Commit

Permalink
fix: fix windows path when invoke (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed May 16, 2020
1 parent ebb84a2 commit e637a0a
Show file tree
Hide file tree
Showing 30 changed files with 116 additions and 86 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/nodejs.yml
Expand Up @@ -4,7 +4,6 @@ on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -24,3 +23,22 @@ jobs:
- run: npm run cov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1


# build-windows:
# runs-on: windows-latest

# strategy:
# matrix:
# node-version: [10.x, 12.x]

# steps:
# - uses: actions/checkout@v2
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v1
# with:
# node-version: ${{ matrix.node-version }}
# - run: npm install
# - run: npm run bootstrap
# - run: npm run build --if-present
# - run: npm run cov
8 changes: 4 additions & 4 deletions packages/egg-layer/package.json
Expand Up @@ -5,10 +5,10 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"test-local": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"test-local": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/faas-cli-command-core/package.json
Expand Up @@ -20,8 +20,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"cov": "midway-bin cov --ts",
"autod": "midway-bin autod"
},
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-cli-plugin-create/package.json
Expand Up @@ -21,9 +21,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-cli-plugin-deploy/package.json
Expand Up @@ -18,9 +18,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/faas-cli-plugin-dev-pack/package.json
Expand Up @@ -23,8 +23,8 @@
},
"scripts": {
"build": " midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-cli-plugin-fc/package.json
Expand Up @@ -23,9 +23,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace --timeout=0",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace --timeout=0",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-cli-plugin-invoke/package.json
Expand Up @@ -32,9 +32,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
22 changes: 17 additions & 5 deletions packages/faas-cli-plugin-invoke/src/index.ts
Expand Up @@ -12,6 +12,7 @@ import * as FCTrigger from '@midwayjs/serverless-fc-trigger';
import * as SCFTrigger from '@midwayjs/serverless-scf-trigger';
import { resolve, relative, join } from 'path';
import { FaaSStarterClass, cleanTarget } from './utils';
import { type } from 'os';
import {
ensureFileSync,
existsSync,
Expand All @@ -30,6 +31,14 @@ enum LOCK_TYPE {
WAITING,
COMPLETE,
}

function getPlatformPath(p) {
if (type() === 'Windows_NT') {
return p.replace(/\\/g, '\\\\');
}
return p;
}

export class FaaSInvokePlugin extends BasePlugin {
baseDir: string;
buildDir: string;
Expand Down Expand Up @@ -152,7 +161,7 @@ export class FaaSInvokePlugin extends BasePlugin {
this.buildDir = resolve(this.baseDir, '.faas_debug_tmp');
const lockKey = `codeAnalyzeResult:${this.baseDir}`;
const { lockType, lockData } = this.getLock(lockKey);
let codeAnalyzeResult: any;
let codeAnalyzeResult;
if (lockType === LOCK_TYPE.INITIAL) {
this.setLock(lockKey, LOCK_TYPE.WAITING);
// 分析目录结构
Expand All @@ -171,7 +180,7 @@ export class FaaSInvokePlugin extends BasePlugin {
}

async copyFile() {
const packageObj: any = this.core.service.package || {};
const packageObj = this.core.service.package || {};
// clean directory first
if (this.options.clean) {
await cleanTarget(this.buildDir);
Expand Down Expand Up @@ -273,7 +282,7 @@ export class FaaSInvokePlugin extends BasePlugin {
],
};
this.core.debug('Code Analysis Params', codeAnyParams);
const newSpec: any = await CodeAny(codeAnyParams);
const newSpec = await CodeAny(codeAnyParams);
this.core.debug('Code Analysis Result', newSpec);
this.core.service.functions = newSpec.functions;
this.setStore('functions', this.core.service.functions);
Expand Down Expand Up @@ -387,6 +396,7 @@ export class FaaSInvokePlugin extends BasePlugin {
} else if (platform === 'tencent') {
starterName = require.resolve('@midwayjs/serverless-scf-starter');
}

if (!starterName) {
return;
}
Expand All @@ -398,8 +408,10 @@ export class FaaSInvokePlugin extends BasePlugin {
functions: this.core.service.functions,
},
distDir: this.buildDir,
starter: starterName,
loadDirectory: isTsMode ? [resolve(this.defaultTmpFaaSOut, 'src')] : [],
starter: getPlatformPath(starterName),
loadDirectory: isTsMode
? [getPlatformPath(resolve(this.defaultTmpFaaSOut, 'src'))]
: [],
});
if (isTsMode) {
// ts模式 midway-core 会默认加载入口文件所在目录下的 src 目录里面的ts代码
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-cli-plugin-package/package.json
Expand Up @@ -27,9 +27,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace --timeout=120000",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace --timeout=120000",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-cli-plugin-scf/package.json
Expand Up @@ -23,9 +23,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace --timeout=0",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace --timeout=0",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-cli-plugin-test/package.json
Expand Up @@ -23,9 +23,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-cli/package.json
Expand Up @@ -38,9 +38,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-dev-pack/package.json
Expand Up @@ -29,9 +29,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/faas-util-ts-compile/package.json
Expand Up @@ -14,9 +14,9 @@
},
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/faas/package.json
Expand Up @@ -37,8 +37,8 @@
},
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/gateway-common-core/package.json
Expand Up @@ -20,9 +20,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/gateway-common-http/package.json
Expand Up @@ -24,9 +24,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-engine/package.json
Expand Up @@ -12,9 +12,9 @@
},
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-mock/package.json
Expand Up @@ -17,9 +17,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/serverless-aws-starter/package.json
Expand Up @@ -18,9 +18,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/serverless-fc-starter/package.json
Expand Up @@ -20,9 +20,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/serverless-fc-trigger/package.json
Expand Up @@ -20,9 +20,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/serverless-http-parser/package.json
Expand Up @@ -23,9 +23,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/serverless-invoke/package.json
Expand Up @@ -20,9 +20,9 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "NODE_ENV=test midway-bin test --ts --full-trace",
"debug": "NODE_ENV=test midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "NODE_ENV=unittest midway-bin cov --ts",
"test": "midway-bin test --ts --full-trace",
"debug": "midway-bin test --ts --full-trace --inspect-brk=9229",
"cov": "midway-bin cov --ts",
"clean": "midway-bin clean",
"autod": "midway-bin autod"
},
Expand Down

0 comments on commit e637a0a

Please sign in to comment.