mirror of https://github.com/embarklabs/embark.git
refactor(@embark/storage): wrap require.resolve in try/catch
Wrap `require.resolve` in try/catch instead of testing the path with `embark.fs.access`.
This commit is contained in:
parent
13e926659f
commit
bd602b45ee
|
@ -99,9 +99,11 @@ class StorageProcessesLauncher {
|
||||||
if (self.processes[storageName]) {
|
if (self.processes[storageName]) {
|
||||||
return callback(__('Storage process already started'));
|
return callback(__('Storage process already started'));
|
||||||
}
|
}
|
||||||
const filePath = require.resolve(`embark-${storageName}/process`, {paths: [embarkPath('node_modules')]});
|
|
||||||
this.embark.fs.access(filePath, (err) => {
|
let filePath;
|
||||||
if (err) {
|
try {
|
||||||
|
filePath = require.resolve(`embark-${storageName}/process`, {paths: [embarkPath('node_modules')]});
|
||||||
|
} catch (e) {
|
||||||
return callback(__('No process file for this storage type (%s) exists. Please start the process locally.', storageName));
|
return callback(__('No process file for this storage type (%s) exists. Please start the process locally.', storageName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,9 +175,8 @@ class StorageProcessesLauncher {
|
||||||
self.events.on('logs:swarm:disable', () => {
|
self.events.on('logs:swarm:disable', () => {
|
||||||
self.processes[storageName].silent = true;
|
self.processes[storageName].silent = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stopProcess(storageName, cb) {
|
stopProcess(storageName, cb) {
|
||||||
if(this.processes[storageName]) {
|
if(this.processes[storageName]) {
|
||||||
this.manualExit = true;
|
this.manualExit = true;
|
||||||
|
|
Loading…
Reference in New Issue