Skip to content

Commit f1e5b74

Browse files
fix: create vars.json file if variables exist (#143)
1 parent dc106e4 commit f1e5b74

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209
"@types/enzyme": "^3.10.9",
210210
"@types/history": "4.7.9",
211211
"@types/jest": "^27.0.2",
212+
"@types/lodash": "^4.17.16",
212213
"@types/node": "17.0.23",
213214
"@types/node-forge": "^1.3.11",
214215
"@types/terser-webpack-plugin": "^5.0.4",

src/renderer/actions/local-sync/fs-manager.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import {
5353
CollectionRecord,
5454
Environment,
5555
EnvironmentVariableValue,
56-
ErroredRecords,
56+
ErroredRecord,
5757
FileSystemResult,
5858
FileTypeEnum,
5959
FsResource,
@@ -66,6 +66,7 @@ import {
6666
parseFileType,
6767
ReadmeRecordFileType,
6868
} from "./file-types/file-types";
69+
import { isEmpty } from "lodash";
6970

7071
export class FsManager {
7172
private rootPath: string;
@@ -187,12 +188,12 @@ export class FsManager {
187188
async getAllRecords(): Promise<
188189
FileSystemResult<{
189190
records: APIEntity[];
190-
erroredRecords: ErroredRecords[];
191+
erroredRecords: ErroredRecord[];
191192
}>
192193
> {
193194
const resourceContainer = await this.parseFolder(this.rootPath, "api");
194195
const entities: APIEntity[] = [];
195-
const erroredRecords: ErroredRecords[] = [];
196+
const erroredRecords: ErroredRecord[] = [];
196197
// eslint-disable-next-line
197198
for (const resource of resourceContainer) {
198199
const entityParsingResult: FileSystemResult<APIEntity> | undefined =
@@ -242,7 +243,7 @@ export class FsManager {
242243
async getAllEnvironments(): Promise<
243244
FileSystemResult<{
244245
environments: Environment[];
245-
erroredRecords: ErroredRecords[];
246+
erroredRecords: ErroredRecord[];
246247
}>
247248
> {
248249
const fileType = new EnvironmentRecordFileType();
@@ -252,7 +253,7 @@ export class FsManager {
252253
);
253254
console.log("ENV CONTAINER", { resourceContainer });
254255
const entities: Environment[] = [];
255-
const erroredRecords: ErroredRecords[] = [];
256+
const erroredRecords: ErroredRecord[] = [];
256257
// eslint-disable-next-line
257258
for (const resource of resourceContainer) {
258259
if (resource.type === "file") {
@@ -1187,7 +1188,7 @@ export class FsManager {
11871188
}
11881189
}
11891190

1190-
if (collection.data.variables) {
1191+
if (!isEmpty(collection.data.variables)) {
11911192
const variablesFile = this.createResource({
11921193
id: appendPath(collectionFolder.path, COLLECTION_VARIABLES_FILE),
11931194
type: "file",

src/renderer/actions/local-sync/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export type CollectionRecord = {
109109
};
110110
};
111111
};
112-
export type ErroredRecords = {
112+
export type ErroredRecord = {
113113
name: string;
114114
path: string;
115115
error: string;

0 commit comments

Comments
 (0)