Skip to content

Commit

Permalink
fix: eslint and typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
@jotadeveloper authored and sergiohgz committed Jul 24, 2019
1 parent e88d36d commit 8b3f153
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/file-locking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"commitmsg": "commitlint -e $GIT_PARAMS",
"coverage": "codecov",
"test": "jest",
"lint": "eslint . --ext .js,.ts",
"lint": "npm run type-check && eslint . --ext .js,.ts",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"build": "babel src/ --out-dir lib/ --copy-files --ignore __tests__",
Expand Down
30 changes: 15 additions & 15 deletions core/file-locking/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import path from 'path';
import { Callback } from '@verdaccio/types';

// locks a file by creating a lock file
const lockFile = function (name: string, callback: Callback) {
const lockFile = function(name: string, callback: Callback) {
const statDir = (name: string) => {
return new Promise((resolve, reject) => {
return new Promise<any>((resolve, reject) => {
// test to see if the directory exists
const dirPath = path.dirname(name);
fs.stat(dirPath, function (err, stats) {
fs.stat(dirPath, function(err, stats) {
if (err) {
return reject(err);
} else if (!stats.isDirectory()) {
Expand All @@ -22,9 +22,9 @@ const lockFile = function (name: string, callback: Callback) {
};

const statfile = (name: string) => {
return new Promise((resolve, reject) => {
return new Promise<any>((resolve, reject) => {
// test to see if the directory exists
fs.stat(name, function (err, stats) {
fs.stat(name, function(err, stats) {
if (err) {
return reject(err);
} else if (!stats.isFile()) {
Expand Down Expand Up @@ -76,9 +76,9 @@ const lockFile = function (name: string, callback: Callback) {
};

// unlocks file by removing existing lock file
const unlockFile = function (name: string, next: Callback) {
const unlockFile = function(name: string, next: Callback) {
const lockFileName = `${name}.lock`;
locker.unlock(lockFileName, function () {
locker.unlock(lockFileName, function() {
return next(null);
});
};
Expand All @@ -92,7 +92,7 @@ const unlockFile = function (name: string, next: Callback) {
* @param {*} options
* @param {*} callback
*/
function readFile(name: string, options: any = {}, callback: any = () => { }) {
function readFile(name: string, options: any = {}, callback: any = () => {}) {
if (typeof options === 'function') {
callback = options;
options = {};
Expand All @@ -101,13 +101,13 @@ function readFile(name: string, options: any = {}, callback: any = () => { }) {
options.lock = options.lock || false;
options.parse = options.parse || false;

const lock = function (options: { lock: string }) {
return new Promise((resolve, reject) => {
const lock = function(options: { lock: string }) {
return new Promise<any>((resolve, reject) => {
if (!options.lock) {
return resolve(null);
}

lockFile(name, function (err: any) {
lockFile(name, function(err: any) {
if (err) {
return reject(err);
}
Expand All @@ -116,9 +116,9 @@ function readFile(name: string, options: any = {}, callback: any = () => { }) {
});
};

const read = function () {
return new Promise((resolve, reject) => {
fs.readFile(name, 'utf8', function (err, contents) {
const read = function() {
return new Promise<any>((resolve, reject) => {
fs.readFile(name, 'utf8', function(err, contents) {
if (err) {
return reject(err);
}
Expand All @@ -128,7 +128,7 @@ function readFile(name: string, options: any = {}, callback: any = () => { }) {
});
};

const parseJSON = function (contents: any) {
const parseJSON = function(contents: any) {
return new Promise((resolve, reject) => {
if (!options.parse) {
return resolve(contents);
Expand Down

0 comments on commit 8b3f153

Please sign in to comment.