UNPKG

node_terminus

Version:

Pantheon Terminus cli wrapper and extensions

44 lines (39 loc) 1.22 kB
const path = require('path') const fs = require('fs') const Base = require('./base') const Docker = require('./docker') const GenerateCommands = require('./generateCommands') let commandGenerator = new GenerateCommands() const Multi = require('./multi') const mkdirp = require('mkdirp') function assertCachePath(cachePath) { try { if (fs.existsSync(cachePath)==false){ console.log(`Creating cache directory ${cachePath}`) mkdirp.sync(cachePath) } } catch(e) { console.log(e) // TODO: Put in central logging. } } //const Namespace = require('./../classes/namespace') class Terminus extends Multi.inherit(Base,Docker) { constructor() { super() let config_token = this.config.machine_token || '' if (typeof(process.env.MACHINE_TOKEN)==='undefined'){ this.config.machine_token = this.config.machine_token } else { this.config.machine_token = process.env.MACHINE_TOKEN } this.name = "terminus" if (typeof(this.config.cache_path)==='undefined') { this.config.cache_path = path.join(this.config.base_path,"cache") } assertCachePath(this.config.cache_path) this.cmd = commandGenerator.generate() } } module.exports = Terminus