UNPKG

990 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3class LockfileError extends Error {
4 constructor({ msg, file, reason }) {
5 super(msg || (reason ? `${reason}: ${file}` : `lock exists!: ${file}`));
6 this.code = 'ELOCK';
7 this.file = file;
8 this.msg = msg;
9 this.reason = reason;
10 }
11}
12exports.LockfileError = LockfileError;
13class RWLockfileError extends LockfileError {
14 constructor(status) {
15 switch (status.status) {
16 case 'write_lock':
17 super({ file: status.file, msg: `write lock exists: ${status.job.reason || ''}` });
18 break;
19 case 'read_lock':
20 super({ file: status.file, msg: `read lock exists: ${status.jobs[0].reason || ''}` });
21 break;
22 default:
23 throw new Error(`Unexpected status: ${status.status}`);
24 }
25 this.status = status;
26 }
27}
28exports.RWLockfileError = RWLockfileError;