Skip to content

Commit e054969

Browse files
committed
enhance 'tests'
1 parent 51e560e commit e054969

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

index.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const BASE_RUNTIME = "provided";
1414
const NO_OUTPUT_CAPTURE = { stdio: ["ignore", process.stdout, process.stderr] };
1515

1616
function includeInvokeHook(serverlessVersion) {
17-
let [major, minor] = serverlessVersion.split('.');
17+
let [major, minor] = serverlessVersion.split(".");
1818
let majorVersion = parseInt(major);
1919
let minorVersion = parseInt(minor);
2020
return majorVersion === 1 && minorVersion >= 38 && minorVersion < 40;
@@ -28,10 +28,10 @@ class RustPlugin {
2828
this.servicePath = this.serverless.config.servicePath || "";
2929
this.hooks = {
3030
"before:package:createDeploymentArtifacts": this.build.bind(this),
31-
"before:deploy:function:packageFunction": this.build.bind(this),
31+
"before:deploy:function:packageFunction": this.build.bind(this)
3232
};
3333
if (includeInvokeHook(serverless.version)) {
34-
this.hooks['before:invoke:local:invoke'] = this.build.bind(this);
34+
this.hooks["before:invoke:local:invoke"] = this.build.bind(this);
3535
}
3636
this.custom = Object.assign(
3737
{
@@ -51,17 +51,21 @@ class RustPlugin {
5151
}
5252

5353
runDocker(funcArgs, cargoPackage, binary) {
54-
const cargoHome = process.env.CARGO_HOME || (path.join(homedir(), ".cargo"));
54+
const cargoHome = process.env.CARGO_HOME || path.join(homedir(), ".cargo");
5555
const cargoRegistry = path.join(cargoHome, "registry");
5656
const cargoDownloads = path.join(cargoHome, "git");
5757
const defaultArgs = [
58-
'run',
59-
'--rm',
60-
'-t',
61-
'-e', `BIN=${binary}`,
62-
`-v`, `${this.servicePath}:/code`,
63-
`-v`, `${cargoRegistry}:/root/.cargo/registry`,
64-
`-v`, `${cargoDownloads}:/root/.cargo/git`,
58+
"run",
59+
"--rm",
60+
"-t",
61+
"-e",
62+
`BIN=${binary}`,
63+
`-v`,
64+
`${this.servicePath}:/code`,
65+
`-v`,
66+
`${cargoRegistry}:/root/.cargo/registry`,
67+
`-v`,
68+
`${cargoDownloads}:/root/.cargo/git`
6569
];
6670
const customArgs = [];
6771
let cargoFlags = (funcArgs || {}).cargoFlags || this.custom.cargoFlags;
@@ -114,9 +118,7 @@ class RustPlugin {
114118
const res = this.runDocker(func.rust, cargoPackage, binary);
115119
if (res.error || res.status > 0) {
116120
this.serverless.cli.log(
117-
`Dockerized Rust build encountered an error: ${res.error} ${
118-
res.status
119-
}.`
121+
`Dockerized Rust build encountered an error: ${res.error} ${res.status}.`
120122
);
121123
throw new Error(res.error);
122124
}

package-lock.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Serverless framework plugin for Rustlang applications",
55
"main": "index.js",
66
"scripts": {
7-
"test": "npx eslint ."
7+
"test": "eslint *.js && prettier --check '*.js'",
8+
"fmt": "prettier --write '*.js'"
89
},
910
"repository": {
1011
"type": "git",
@@ -28,7 +29,8 @@
2829
"serverless": "^1.53.0"
2930
},
3031
"devDependencies": {
31-
"eslint": "^6.5.0"
32+
"eslint": "^6.5.0",
33+
"prettier": "^1.18.2"
3234
},
3335
"files": [
3436
"index.js",

0 commit comments

Comments
 (0)