示例#1
0
module.exports.prototype.loadScript = function(script, next) {
  var self = this
  var scriptLocations = [
    script,
    path.join(process.cwd(), script),
    path.join(process.cwd(), "node_modules", script),
    path.join(home(), "angel", script),
    path.join(home(), "angel", "scripts", script)
  ]
  async.detectSeries(scriptLocations, fs.exists, function(found){
    if(!found) { return next(new Error(script+" not found in "+scriptLocations)) }
    try {
      var m = require(found) // TODO do not require at all non-angel modules
      if (typeof m === 'function') {
        self.loadedModules.push(m)
        // if exported func is async reaction (context, next)
        if(m.length === 2)
          return m(self.contextFn(), next)
        // otherwise invoke it directly and pass forward
        m(self.contextFn())
      }
    } catch(err){
      return next(err)
    }
    next()
  })
}
示例#2
0
/**
 * where the userland data directory resides
 * includes things like the runtime files
 * @return {string} directory for data
 */
function userDataDir() {
  // Userland specific
  if (process.platform === 'darwin') {
    return home('Library/Jupyter');
  } else if (process.platform === 'win32') {
    return path.resolve(path.join(process.env.APPDATA, 'jupyter'));
  }
  // TODO: respect XDG_DATA_HOME
  return home('.local/share/jupyter');
}
示例#3
0
test('nodeGypPath(): accepts any arguments', function (t) {
  var nodeGypPath = util.nodeGypPath
  t.equal(nodeGypPath('0.10.40', 'include/node'),
          home() + '/.node-gyp/0.10.40/include/node')
  t.equal(nodeGypPath('4.1.0', 'include/node', 'node.h'),
          home() + '/.node-gyp/4.1.0/include/node/node.h')
  t.equal(nodeGypPath('/iojs-1.0.4/', '/include/node/', '/node.h'),
          home() + '/.node-gyp/iojs-1.0.4/include/node/node.h',
          'trailing slashes should not matter')
  t.end()
})
示例#4
0
  definePaths: function (options) {
    // node server/config stuff
    options.xt.id = lib.util.$(options);
    options.xt.configdir = path.resolve(exports.etcXtuple, options.xt.id);
    options.xt.configfile = path.resolve(options.xt.configdir, 'config.js');
    options.xt.ssldir = path.resolve(options.xt.configdir, 'ssl');
    options.xt.homedir = path.resolve(exports.usrLocalXtuple);
    options.xt.dist = path.resolve(options.local.workspace, '..');

    // shared config (per account)
    options.xt.userhome = home();
    options.xt.userconfig = path.resolve(options.xt.userhome, '.xtuple');
    options.xt.typeconfig = path.resolve(options.xt.userconfig, options.type);
    options.xt.rand64file = path.resolve(options.xt.typeconfig, 'rand64.txt');
    options.xt.key256file = path.resolve(options.xt.typeconfig, 'key256.txt');
    options.xt.userdist = options.xt.dist;
    options.xt.coredir = options.local.workspace;

    // other system paths
    options.xt.logdir = path.resolve(exports.varLog, 'xtuple', options.xt.id);
    options.pg.logdir = path.resolve(exports.varLog, 'postgresql');
    options.xt.socketdir = path.resolve('/var/run/postgresql');
    options.xt.rundir = path.resolve(exports.varRun, 'xtuple', options.xt.id);
    options.xt.statedir = path.resolve(exports.varLibXtuple, options.xt.id);

    options.pg.snapshotdir = path.resolve(exports.varLibXtuple, options.xt.id, 'snapshots');
  },
示例#5
0
test('prebuildCache() for different environments', function (t) {
  var APPDATA = process.env.APPDATA = 'somepathhere'
  t.equal(util.prebuildCache(), APPDATA + '/npm-cache/_prebuilds', 'APPDATA set')
  delete process.env.APPDATA
  t.equal(util.prebuildCache(), home() + '/.npm/_prebuilds', 'APPDATA not set')
  t.end()
})
示例#6
0
文件: publish.js 项目: 315ea/frontend
 return new Promise(function (resolve, reject) {
     var propertiesFile = path.join(homeDir(), '.gu', 'frontend.properties');
     var npmAuthToken = properties.of(propertiesFile).get(authTokenKey);
     if (typeof npmAuthToken === 'undefined') {
         reject(new Error('noauth'));
     } else {
         resolve(npmAuthToken);
     }
 });
示例#7
0
module.exports = function Angel(){
  var self = this
  this.dnaSources = [
    path.join(process.cwd(), "dna", "angel.json"),
    path.join(process.cwd(), "dna", "angel"),
    path.join(process.cwd(), "angel.json"),
    path.join(home(), "angel.json"),
    path.join(home(), "angel", "dna")
  ]

  this.plasma = new Plasma();
  this.reactor = new Reactor()
  this.abilities = new Loader(function(){
    return self
  })
  this.scripts = new Loader(function(){
    return self.clone()
  })
}
示例#8
0
  copySshDirectory: function (options) {
    var rootSsh = path.resolve('/root', '.ssh');
    if (!fs.existsSync(rootSsh)) {
      mkdirp.sync(rootSsh);
    }

    _.each(glob.sync(path.resolve(home(), '.ssh', '*')), function (file) {
      var target = path.resolve(rootSsh, path.basename(file));
      cp.sync(file, target);
      fs.chownSync(target, 0, 0);
      fs.chmodSync(target, '600');
    });
  },
示例#9
0
文件: npm-paths.js 项目: avmi/dev201x
module.exports = function npmPaths () {
  var paths = [];

  // Walk up the CWD and add `node_modules/` folder lookup on each level
  process.cwd().split(path.sep).forEach(function (part, i, parts) {
    var lookup = path.join.apply(path, parts.slice(0, i + 1).concat(['node_modules']));

    if (!win32) {
      lookup = '/' + lookup;
    }

    paths.push(lookup);
  });

  // Adding global npm directories
  // We tried using npm to get the global modules path, but it haven't work out
  // because of bugs in the parseable implementation of `ls` command and mostly
  // performance issues. So, we go with our best bet for now.
  if (process.env.NODE_PATH) {
    paths = compact(process.env.NODE_PATH.split(path.delimiter)).concat(paths);
  } else {
    // global node_modules should be 5 directory up this one (most of the time)
    paths.push(path.join(__dirname, '../../../..'));

    // adds support for generator resolving when yeoman-generator has been linked
    paths.push(path.join(path.dirname(process.argv[1]), '../..'));

    // Default paths for each system
    if (win32) {
      paths.push(path.join(process.env.APPDATA, 'npm/node_modules'));
    } else {
      paths.push('/usr/lib/node_modules');
      paths.push('/usr/local/lib/node_modules');
    }
  }
  
  // nvm on os x
  // For some reason, nvm doens't get put on NODE_PATH
  // unless you do it manually.
  if (!win32) {
    paths.push(homeDir('.nvm/*/lib/node_modules'));
  }
  
  return paths.reverse();
};
示例#10
0
function configDirs(opts) {
  var paths = [];
  if (process.env.JUPYTER_CONFIG_DIR) {
    paths.push(process.env.JUPYTER_CONFIG_DIR);
  }

  paths.push(home('.jupyter'));

  if (opts && opts.withSysPrefix) {
    return sysPrefixPromise()
            .then(sysPrefix => path.join(sysPrefix, 'etc', 'jupyter'))
            .then(sysPathed => {
              paths.push(sysPathed);
              return paths.concat(systemConfigDirs());
            });
  }
  return paths.concat(systemConfigDirs());
}
示例#11
0
var lib = require('xtuple-server-lib'),
  rimraf = require('rimraf'),
  mkdirp = require('mkdirp'),
  path = require('path'),
  fs = require('fs'),
  _ = require('lodash'),
  home = require('home-dir'),
  prefix = path.resolve(home(), '.xtuple');

/**
 * Sets up system file and directory paths
 */
_.extend(exports, lib.task, /** @exports xtuple-server-local-paths */ {

  etcXtuple: path.resolve(prefix, 'etc/xtuple'),
  usrLocal: path.resolve(prefix, 'usr/local'),
  usrLocalXtuple: path.resolve(prefix, 'usr/local/xtuple'),
  usrSbin: path.resolve(prefix, 'usr/sbin'),
  varLog: path.resolve(prefix, 'var/log'),
  varLibXtuple: path.resolve(prefix, 'var/lib/xtuple'),
  varRun: path.resolve(prefix, 'var/run'),

  options: {
    workspace: {
      optional: '[path]',
      description: 'The path of the local workspace in which to install',
      value: process.cwd(),
      validate: function (value) {
        log.info('local-workspace', value);
        var pkg = require(path.resolve(value, 'package'));
示例#12
0
文件: config.js 项目: byteclubfr/manu
const homeDir = require('home-dir')

const CACHE_PATH = '.manu-pages'

exports.HTML_PATH = homeDir(`${CACHE_PATH}/html`)
exports.JSON_PATH = homeDir(`${CACHE_PATH}/json`)
exports.MD_PATH = homeDir(`${CACHE_PATH}/md`)

示例#13
0
#!/usr/bin/env node

var fs = require('fs')
var join = require('path').join
var spawn = require('child_process').spawn
var argv = require('minimist')(process.argv.slice(2))

var home = require('home-dir')
var request = require('hyperquest')
var concat = require('concat-stream')
var async = require('async')
var c = require('chalk')

var configDir = join(home(), '.config')
var tokenFile = join(configDir, 'cloneall-token')

function getRepos(org, cb){
  getToken(function(err, token){
    if (err) return cb(err)
    var all_repos = []

    function getNextUrl(link) {
      if (link === undefined) return
      var match = /<(.*)>; rel="next"/.exec(link)
      return match && match[1]
    }

    function get(url) {
      console.log(c.green('Fetching repo data from:'), c.yellow(url))
      var req = request.get(url)
示例#14
0
var netlify = require("netlify"),
    path    = require("path"),
    homeDir = require("home-dir"),
    fs      = require("fs"),
    chalk   = require("chalk"),
    webauth = require("./webauth");

var CLIENT_ID         = process.env.NETLIFY_CLIENT_ID || "5edad8f69d47ae8923d0cf0b4ab95ba1415e67492b5af26ad97f4709160bb31b",
    API_ENDPOINT      = process.env.NETLIFY_ENDPOINT,
    PREVIEW_DOMAIN    = process.env.NETLIFY_PREVIEW_DOMAIN || "netlify.com",
    CONFIG_DIR        = path.join(homeDir(), '.netlify'),
    CONFIG_PATH       = path.join(CONFIG_DIR, "config"),
    LOCAL_CONFIG_PATH = path.join(process.cwd(), ".netlify");

var readLocalConfig = function(env) {
  if (fs.existsSync(LOCAL_CONFIG_PATH)) {
    conf = JSON.parse(fs.readFileSync(LOCAL_CONFIG_PATH));
    return env ? conf[env] : conf;
  }
  return null;
}

var Config = function(options) {
  for (var k in options) {
    this[k] = options[k]
  }
}

var isUUID = function(val) {
  if (val.indexOf("-") == -1) { return false }
  var parts = val.split("-");
示例#15
0
#!/usr/bin/env node

var path = require('path');
var mkdirp = require('mkdirp');
var feedback = require('feedback');
var startApp = require('../lib/divshot');
var homdeDir = require('home-dir');

// Create our .divshot directory
mkdirp(path.join(homdeDir(), '.divshot', 'config'), function (err) {
  if (err) {
    return feedback.error('Looks like we don\'t have access to your home directory. Please adjust your permissions before you continue');
  }
  
  startApp({
    host: 'https://api.divshot.com',
    // host: 'http://api.dev.divshot.com:9393'
  });
});
示例#16
0
export function _dirForSimulatorDevice(udid: string) {
  return path.resolve(homeDir(), 'Library/Developer/CoreSimulator/Devices', udid);
}
示例#17
0
import { getCurrentWindow } from 'remote';
import home from 'home-dir';
import path from 'path'

const HOME = home();

function _tildify(home, p) {
  const s = path.normalize(p) + path.sep;
  return (s.indexOf(home) === 0 ? s.replace(home + path.sep, '~' + path.sep) : s).slice(0, -1);
}

function tildify(path) {
  if(!path){
    return ''
  }
  return _tildify(HOME, path)
}

export function initNativeHandlers(store) {
  store
    .map(state => {
      const { executionState, filename } = state;
      return {
        title: `${tildify(filename) || 'Untitled'} - ${executionState}`,
        path: filename,
      };
    })
    .distinctUntilChanged()
    .debounceTime(200)
    .subscribe(res => {
      const win = getCurrentWindow();
示例#18
0
 fs.readFile = function (fpath, encoding, cb) {
   t.equal(fpath, home() + '/.node-gyp/' + v + '/src/' + file, 'corect file name')
   cb()
 }