chore(#197): ran prettier on packages/bruno-electron

This commit is contained in:
Anoop M D
2023-09-22 00:36:42 +05:30
parent ae692dde06
commit 67fe264494
18 changed files with 810 additions and 725 deletions

View File

@@ -2,11 +2,11 @@ const cancelTokens = {};
const saveCancelToken = (uid, axiosRequest) => {
cancelTokens[uid] = axiosRequest;
}
};
const deleteCancelToken = (uid) => {
delete cancelTokens[uid];
}
};
module.exports = {
cancelTokens,

View File

@@ -4,7 +4,7 @@ const { customAlphabet } = require('nanoid');
const uuid = () => {
// https://github.com/ai/nanoid/blob/main/url-alphabet/index.js
const urlAlphabet = 'useandom26T198340PX75pxJACKVERYMINDBUSHWOLFGQZbfghjklqvwyzrict';
const customNanoId = customAlphabet (urlAlphabet, 21);
const customNanoId = customAlphabet(urlAlphabet, 21);
return customNanoId();
};
@@ -12,18 +12,18 @@ const uuid = () => {
const stringifyJson = async (str) => {
try {
return JSON.stringify(str, null, 2);
} catch(err) {
} catch (err) {
return Promise.reject(err);
}
}
};
const parseJson = async (obj) => {
try {
return JSON.parse(obj);
} catch(err) {
} catch (err) {
return Promise.reject(err);
}
}
};
const simpleHash = (str) => {
let hash = 0;
@@ -39,7 +39,7 @@ const generateUidBasedOnHash = (str) => {
const hash = simpleHash(str);
return `${hash}`.padEnd(21, '0');
}
};
module.exports = {
uuid,

View File

@@ -4,7 +4,7 @@ const fsPromises = require('fs/promises');
const { dialog } = require('electron');
const isValidPathname = require('is-valid-path');
const exists = async p => {
const exists = async (p) => {
try {
await fsPromises.access(p);
return true;
@@ -13,7 +13,7 @@ const exists = async p => {
}
};
const isSymbolicLink = filepath => {
const isSymbolicLink = (filepath) => {
try {
return fs.existsSync(filepath) && fs.lstatSync(filepath).isSymbolicLink();
} catch (_) {
@@ -21,7 +21,7 @@ const isSymbolicLink = filepath => {
}
};
const isFile = filepath => {
const isFile = (filepath) => {
try {
return fs.existsSync(filepath) && fs.lstatSync(filepath).isFile();
} catch (_) {
@@ -29,7 +29,7 @@ const isFile = filepath => {
}
};
const isDirectory = dirPath => {
const isDirectory = (dirPath) => {
try {
return fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory();
} catch (_) {
@@ -37,14 +37,14 @@ const isDirectory = dirPath => {
}
};
const normalizeAndResolvePath = pathname => {
const normalizeAndResolvePath = (pathname) => {
if (isSymbolicLink(pathname)) {
const absPath = path.dirname(pathname);
const targetPath = path.resolve(absPath, fs.readlinkSync(pathname));
if (isFile(targetPath) || isDirectory(targetPath)) {
return path.resolve(targetPath);
}
console.error(`Cannot resolve link target "${pathname}" (${targetPath}).`)
console.error(`Cannot resolve link target "${pathname}" (${targetPath}).`);
return '';
}
return path.resolve(pathname);
@@ -53,29 +53,29 @@ const normalizeAndResolvePath = pathname => {
const writeFile = async (pathname, content) => {
try {
fs.writeFileSync(pathname, content, {
encoding: "utf8"
encoding: 'utf8'
});
} catch (err) {
return Promise.reject(err);
}
};
const hasJsonExtension = filename => {
if (!filename || typeof filename !== 'string') return false
return ['json'].some(ext => filename.toLowerCase().endsWith(`.${ext}`))
}
const hasJsonExtension = (filename) => {
if (!filename || typeof filename !== 'string') return false;
return ['json'].some((ext) => filename.toLowerCase().endsWith(`.${ext}`));
};
const hasBruExtension = filename => {
if (!filename || typeof filename !== 'string') return false
return ['bru'].some(ext => filename.toLowerCase().endsWith(`.${ext}`))
}
const hasBruExtension = (filename) => {
if (!filename || typeof filename !== 'string') return false;
return ['bru'].some((ext) => filename.toLowerCase().endsWith(`.${ext}`));
};
const createDirectory = async (dir) => {
if(!dir) {
if (!dir) {
throw new Error(`directory: path is null`);
}
if (fs.existsSync(dir)){
if (fs.existsSync(dir)) {
throw new Error(`directory: ${dir} already exists`);
}
@@ -108,7 +108,7 @@ const searchForFiles = (dir, extension) => {
}
}
return results;
}
};
const searchForBruFiles = (dir) => {
return searchForFiles(dir, '.bru');