Skip to content

Commit 1ff06dd

Browse files
committed
Fixed lint errors
1 parent 138f303 commit 1ff06dd

File tree

4 files changed

+109
-106
lines changed

4 files changed

+109
-106
lines changed

npm/package.js

+52-53
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,78 @@ var shell = require('shelljs'),
44
fs = require('fs'),
55
exists,
66
codegen,
7+
codegens,
78
codegen_path,
89
getSubfolders,
910
individual_test,
10-
commandOut,
11-
pwd = shell.pwd();
11+
commandOut;
1212

13-
const args = process.argv[2],
13+
const args = process.argv[2],
1414
PATH_TO_CODEGENS_FOLDER = path.resolve(__dirname, '../codegens');
1515

1616
// throw JS error when any shell.js command encounters an error
17-
shell.config.fatal=true;
17+
shell.config.fatal = true;
1818

1919
// ensure that the working tree is clean before packaging
2020
commandOut = shell.exec('source ./npm/package/require_clean_work_tree.sh');
2121
if (commandOut.code !== 0) {
22-
shell.exit(1);
22+
shell.exit(1);
2323
}
2424

2525
getSubfolders = (folder) => {
26-
return fs.readdirSync(folder)
27-
.map((subfolder) => { return { path: path.join(folder, subfolder), name: subfolder}; })
28-
.filter((obj) => { return fs.statSync(obj.path).isDirectory(); });
26+
return fs.readdirSync(folder)
27+
.map((subfolder) => { return { path: path.join(folder, subfolder), name: subfolder}; })
28+
.filter((obj) => { return fs.statSync(obj.path).isDirectory(); });
2929
};
3030

3131
individual_test = (codegen) => {
3232

33-
console.log(`Creating package for ${codegen}`);
34-
async.series([
35-
function (next) {
36-
console.log(`Running codegen test for codegen ${codegen}`);
37-
commandOut = shell.exec(`npm run test ${codegen} --color always`, {silent: true});
38-
if(commandOut.code !==0) {
39-
console.error(`Failed to run codegen test on codegen ${codegen}, here\'s the error:`);
40-
return next(commandOut.stderr);
41-
}
42-
console.log(commandOut.stdout);
43-
return next();
44-
},
45-
function (next) {
46-
console.log(`Generating zip for codegen ${codegen}`);
47-
commandOut = shell.exec(`npm run zip ${codegen} --color always`, {silent: true});
48-
if(commandOut.code !==0) {
49-
console.error(`Failed to zip codegen ${codegen}, here\'s the error:`);
50-
return next(commandOut.stderr);
51-
}
52-
console.log(commandOut.stdout);
53-
}
54-
], (err) => {
55-
console.error(err);
56-
shell.exit(1);
57-
});
58-
}
33+
console.log(`Creating package for ${codegen}`);
34+
async.series([
35+
function (next) {
36+
console.log(`Running codegen test for codegen ${codegen}`);
37+
commandOut = shell.exec(`npm run test ${codegen} --color always`);
38+
if (commandOut.code !== 0) {
39+
console.error(`Failed to run codegen test on codegen ${codegen}, here's the error:`);
40+
return next(commandOut.stderr);
41+
}
42+
console.log(commandOut.stdout);
43+
return next();
44+
},
45+
function (next) {
46+
console.log(`Generating zip for codegen ${codegen}`);
47+
commandOut = shell.exec(`npm run zip ${codegen} --color always`);
48+
if (commandOut.code !== 0) {
49+
console.error(`Failed to zip codegen ${codegen}, here's the error:`);
50+
return next(commandOut.stderr);
51+
}
52+
console.log(commandOut.stdout);
53+
}
54+
], (err) => {
55+
console.error(err);
56+
shell.exit(1);
57+
});
58+
};
5959

6060
if (args) {
61-
codegen = args;
62-
codegen_path = path.join(PATH_TO_CODEGENS_FOLDER, codegen);
63-
try {
64-
exists=fs.statSync(codegen_path).isDirectory();
65-
} catch (err) {
66-
console.log(`Codegen ${codegen} doesn't exist, please enter a valid name`);
67-
console.log(err);
68-
shell.exit(1);
69-
}
70-
if (exists) {
71-
individual_test(codegen);
72-
}
61+
codegen = args;
62+
codegen_path = path.join(PATH_TO_CODEGENS_FOLDER, codegen);
63+
try {
64+
exists = fs.statSync(codegen_path).isDirectory();
65+
}
66+
catch (err) {
67+
console.log(`Codegen ${codegen} doesn't exist, please enter a valid name`);
68+
console.log(err);
69+
shell.exit(1);
70+
}
71+
if (exists) {
72+
individual_test(codegen);
73+
}
7374
}
7475
else {
75-
console.log('Packaging all the codegens');
76-
var codegens = getSubfolders(PATH_TO_CODEGENS_FOLDER);
77-
codegens.forEach((codegen)=>{
78-
individual_test(codegen.name);
79-
});
76+
console.log('Packaging all the codegens');
77+
codegens = getSubfolders(PATH_TO_CODEGENS_FOLDER);
78+
codegens.forEach((codegen) => {
79+
individual_test(codegen.name);
80+
});
8081
}
81-
82-

npm/zip.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
var shell = require('shelljs'),
22
path = require('path'),
3-
async = require('async'),
43
fs = require('fs'),
54
codegen_path,
65
commandOut,
7-
pwd = shell.pwd();
6+
exists;
87

98
const codegen = process.argv[2],
10-
PATH_TO_CODEGENS_FOLDER = path.resolve(__dirname, '../codegens');
9+
PATH_TO_CODEGENS_FOLDER = path.resolve(__dirname, '../codegens');
1110

1211
// throw JS error when any shell.js command encounters an error
13-
shell.config.fatal=true;
12+
shell.config.fatal = true;
1413

1514
codegen_path = path.join(PATH_TO_CODEGENS_FOLDER, codegen);
1615

1716
try {
18-
exists=fs.statSync(codegen_path).isDirectory();
19-
} catch (err) {
20-
console.log(`Codegen ${codegen} doesn't exist, please enter a valid name`);
21-
shell.exit(1);
17+
exists = fs.statSync(codegen_path).isDirectory();
18+
}
19+
catch (err) {
20+
console.log(`Codegen ${codegen} doesn't exist, please enter a valid name`);
21+
shell.exit(1);
2222
}
2323
if (exists) {
24-
console.log(`${codegen} : zip`);
25-
shell.pushd(codegen_path, "q");
26-
commandOut = shell.exec('npm pack --color always');
27-
if(commandOut.code !==0) {
28-
console.error(`Failed to run pre-package.js for codegen ${codegen}, here\'s the error:`);
29-
console.log(commandOut.stderr);
30-
shell.exit(1);
31-
}
32-
shell.popd(null, "q");
33-
}
24+
console.log(`${codegen} : zip`);
25+
shell.pushd(codegen_path, 'q');
26+
commandOut = shell.exec('npm pack --color always');
27+
if (commandOut.code !== 0) {
28+
console.error(`Failed to run pre-package.js for codegen ${codegen}, here's the error:`);
29+
console.log(commandOut.stderr);
30+
shell.exit(1);
31+
}
32+
shell.popd(null, 'q');
33+
}
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
11
{
2-
"info": {
3-
"_postman_id": "7da8f1cd-aeb0-420f-a989-d47db46b44b0",
4-
"name": "Multipart/form-data FILE",
5-
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
6-
},
7-
"item": [
8-
{
9-
"name": "Single/multiple file upload via form-data",
10-
"request": {
11-
"method": "POST",
12-
"header": [],
13-
"body": {
14-
"mode": "formdata",
15-
"formdata": [
16-
{
2+
"info": {
3+
"_postman_id": "7da8f1cd-aeb0-420f-a989-d47db46b44b0",
4+
"name": "Multipart/form-data FILE",
5+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
6+
},
7+
"item": [
8+
{
9+
"name": "Single/multiple file upload via form-data",
10+
"request": {
11+
"method": "POST",
12+
"header": [],
13+
"body": {
14+
"mode": "formdata",
15+
"formdata": [
16+
{
1717
"key": "single file",
1818
"value": "",
1919
"type": "file",
20-
"src": "<file path>"
21-
},
22-
{
20+
"src": "/home/shivanshsrivastava/Desktop/GSOC/postman-code-generators/dummyFile1.txt"
21+
},
22+
{
2323
"key": "multiple files",
2424
"value": "",
2525
"type": "file",
26-
"src": ["<file path 1>","<file path 2>"]
26+
"src": [
27+
"/home/shivanshsrivastava/Desktop/GSOC/postman-code-generators/dummyFile2.txt",
28+
"/home/shivanshsrivastava/Desktop/GSOC/postman-code-generators/dummyFile3.txt"
29+
]
2730
}
28-
]
29-
},
30-
"url": {
31-
"raw": "https://postman-echo.com/post",
32-
"protocol": "https",
33-
"host": [
34-
"postman-echo",
35-
"com"
36-
],
37-
"path": [
38-
"post"
39-
]
40-
}
41-
}
31+
]
32+
},
33+
"url": {
34+
"raw": "https://postman-echo.com/post",
35+
"protocol": "https",
36+
"host": [
37+
"postman-echo",
38+
"com"
39+
],
40+
"path": [
41+
"post"
42+
]
43+
}
44+
}
4245
}
43-
]
46+
]
4447
}

test/codegen/structure.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const expectedOptions = {
4141
name: 'Set request timeout',
4242
type: 'positiveInteger',
4343
default: 0,
44-
description: 'Set number of milliseconds the request should wait for a response before timing out (use 0 for infinity)'
44+
description: 'Set number of milliseconds the request should wait' +
45+
'for a response before timing out (use 0 for infinity)'
4546
},
4647
followRedirect: {
4748
name: 'Follow redirects',

0 commit comments

Comments
 (0)