mirror of https://github.com/embarklabs/embark.git
move storageUtils
This commit is contained in:
parent
2ed7238190
commit
a1fa4ed30d
|
@ -1,7 +1,6 @@
|
|||
const child_process = require('child_process');
|
||||
const ProcessWrapper = require('../processWrapper');
|
||||
const constants = require('../../constants');
|
||||
const StorageUtils = require('./storageUtils');
|
||||
|
||||
let ipfsProcess; // eslint-disable-line no-unused-vars
|
||||
|
||||
|
@ -10,7 +9,7 @@ class IPFSProcess extends ProcessWrapper {
|
|||
super();
|
||||
|
||||
this.cors = options.cors;
|
||||
this.command = StorageUtils.getCommand('ipfs', options);
|
||||
this.command = 'ipfs';
|
||||
|
||||
this.checkIPFSVersion();
|
||||
this.startIPFSDaemon();
|
||||
|
|
|
@ -3,9 +3,13 @@ const shellJs = require('shelljs');
|
|||
const utils = require('../../utils/utils');
|
||||
const ProcessLauncher = require('../processLauncher');
|
||||
const constants = require('../../constants');
|
||||
const StorageUtils = require('./storageUtils');
|
||||
const {canonicalHost} = require('../../utils/host');
|
||||
|
||||
let References = {
|
||||
ipfs: 'https://ipfs.io/docs/install/',
|
||||
swarm: 'http://swarm-guide.readthedocs.io/en/latest/installation.html'
|
||||
}
|
||||
|
||||
class StorageProcessesLauncher {
|
||||
constructor(options) {
|
||||
this.logger = options.logger;
|
||||
|
@ -89,10 +93,12 @@ class StorageProcessesLauncher {
|
|||
return callback(__('No process file for this storage type (%s) exists. Please start the process locally.', storageName));
|
||||
}
|
||||
|
||||
const program = shellJs.which(StorageUtils.getCommand(storageName, self.storageConfig));
|
||||
let cmd = (storageName === 'swarm' ? (self.storageConfig.swarmPath || 'swarm') : 'ipfs');
|
||||
|
||||
const program = shellJs.which(cmd);
|
||||
if (!program) {
|
||||
self.logger.warn(__('{{storageName}} is not installed or your configuration is not right', {storageName}).yellow);
|
||||
self.logger.info(__('You can install and get more information here: ').yellow + StorageUtils.getStorageInstallationSite(storageName).underline);
|
||||
self.logger.info(__('You can install and get more information here: ').yellow + References[storageName].underline);
|
||||
return callback(__('%s not installed', storageName));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
const IPFS = 'ipfs';
|
||||
const SWARM = 'swarm';
|
||||
|
||||
class StorageUtils {
|
||||
static getCommand(storageName, config) {
|
||||
if (storageName === IPFS) {
|
||||
return IPFS;
|
||||
}
|
||||
if (storageName === SWARM) {
|
||||
return config.swarmPath || SWARM;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static getStorageInstallationSite(storageName) {
|
||||
if (storageName === IPFS) {
|
||||
return 'https://ipfs.io/docs/install/';
|
||||
}
|
||||
if (storageName === SWARM) {
|
||||
return 'http://swarm-guide.readthedocs.io/en/latest/installation.html';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StorageUtils;
|
|
@ -2,7 +2,6 @@ const child_process = require('child_process');
|
|||
const ProcessWrapper = require('../processWrapper');
|
||||
const constants = require('../../constants');
|
||||
const fs = require('../../core/fs');
|
||||
const StorageUtils = require('./storageUtils');
|
||||
|
||||
let swarmProcess;
|
||||
|
||||
|
@ -11,7 +10,7 @@ class SwarmProcess extends ProcessWrapper {
|
|||
super();
|
||||
this.storageConfig = options.storageConfig;
|
||||
this.cors = options.cors;
|
||||
this.command = StorageUtils.getCommand('swarm', this.storageConfig);
|
||||
this.command = this.storageConfig.swarmPath || 'swarm';
|
||||
}
|
||||
|
||||
startSwarmDaemon() {
|
||||
|
|
Loading…
Reference in New Issue