123456789101112131415161718192021222324252627282930313233 |
- const isRoot = require('is-root');
- const hostile = require('hostile');
- const colors = require('colors');
- const docker = require('docker-compose');
- const log = require('../inc/log');
- const ProjectEnvironment = require('../classes/ProjectEnvironment');
- const uninstallHosts = (hosts) => {
- if (!isRoot()) {
- log.warn('Unable to unset hosts because you need root privileges');
- } else {
- for (var ip in hosts) {
- const hostsString = hosts[ip].join(' ');
- log.log('Uninstalling hosts for %s: %s', ip, hostsString);
- hostile.remove(ip, hostsString);
- }
- }
- };
- const stopServices = async (projectEnv) => {
- await docker.down(projectEnv.getDockerOptions());
- };
- module.exports = (env) => {
- const projectEnv = new ProjectEnvironment(process.cwd(), env);
- log.log("Shutting down project (%s environment)...", colors.bold(env));
- uninstallHosts(projectEnv.getHosts());
- stopServices(projectEnv);
- };
|