0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-03 23:09:17 -05:00
verdaccio/packages/core/file-locking/src/lockfile.ts
Juan Picado 3838d3d212 feat: relocate core packages (#1906)
* chore: clean lint warnings

* refactor: move core packages
2021-04-09 17:54:13 +02:00

29 lines
557 B
TypeScript

import { Callback } from '@verdaccio/types';
import { lockfile, statDir, statfile } from './utils';
/**
* locks a file by creating a lock file
* @param name
* @param callback
*/
const lockFile = function (name: string, callback: Callback): void {
Promise.resolve()
.then(() => {
return statDir(name);
})
.then(() => {
return statfile(name);
})
.then(() => {
return lockfile(name);
})
.then(() => {
callback(null);
})
.catch((err) => {
callback(err);
});
};
export { lockFile };