How to use the private/core.once function in private

To help you get started, we’ve selected a few private examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seedjs / seed / lib / commands / install.js View on Github external
prepare: function(desc, done) {
    var job = desc.prepareJob;
    if (!job) {
      var context = this;
      job = desc.prepareJob = CORE.once(function(done) {
        // if we already have a local path, then this package is already
        // prepared for install
        if (desc.path) return done();
        
        // Otherwise, we should have a remote that we can ask to fetch
        if (!desc.remote) {
          return done('internal error: missing remote '+CORE.inspect(desc));
        }
        
        desc.remote.fetch(desc.info, function(err, path) {
          if (!err && !path) {
            err = "Could not fetch "+desc.packageId + ' ('+desc.version+')';
          }
          if (err) return done(err);
          desc.path = path;
          return done();
github seedjs / seed / lib / commands / freeze.js View on Github external
function freezePackage(workingPackage, vers, force, dirname) {

  // compute the root to install at
  var dstRoot = CORE.path.join(workingPackage.path, dirname);
  var mkdstRoot = CORE.once(function(done) {
    CORE.fs.mkdir_p(dstRoot, 511, done);
  });
  
  return function(packageId, done) {
    CORE.async(function() {
      var pkg, dstPath;
      
      // find the requested package in the repos
      pkg = require.packageFor(packageId, vers);
      if (!pkg) throw new Error(packageId+' '+vers+' not found');

      // remove existing copy if forced or throw error
      dstPath = CORE.path.join(dstRoot, pkg.get('name'));
      if (CORE.fs.exists(dstPath)) {
        if (!force) {
          throw new Error(packageId+' already exists in working package.  Use --force to override');
github seedjs / seed / lib / commands / install.js View on Github external
function(desc, done) {
      if (!desc) return done(packageId + ' not found');
      
      var job = desc.installJob;
      if (!job) {
        job = desc.installJob = CORE.once(function(done) {

          // satisfy dependencies first...
          CORE.iter.chain(function(done) {
            context.prepare(desc, function(err) {
              if (err) return done(err);
              context.installDependencies(desc, CORE.err(done));
            });

          // then open this package and install it
          }, function(done) {
            var loadPackage = CORE.async(function() {
              return require.packageFor(desc.path);
            });
            
            loadPackage(function(err, pkg) {
              if (!err & !pkg) err = packageId  + ' is invalid';
github seedjs / seed / lib / commands.js View on Github external
*/
Cmds.collectPluginInfo = function(key, packages) {
  var ret = {};
  if (!packages) packages = require.catalogPackages();
  packages.forEach(function(pkg) {
    var info = pkg.get(key);
    if (info) ret[pkg.id] = info;
  });
  
  return ret ;
};

/**
  Invokes callback with hash of commands mapped to property paths
*/
Cmds.commands = CORE.once(function(done) {
  var pluginInfo = Cmds.collectPluginInfo('seed:commands');
    
  var ret = CORE.mixin({}, pluginInfo['seed']);
  Object.keys(pluginInfo).forEach(function(packageId) {
    if (packageId === 'seed') return ; // skip since we put it there first
    
    var commands = pluginInfo[packageId];
    if (!commands) return ; // nothing to do
    
    for(var key in commands) {
      if (!commands.hasOwnProperty(key)) continue;
      var path = commands[key];
      if (path.indexOf(':')<0) path = packageId + ':' + path; // namespace 
      ret[key.toLowerCase()] = path;
    }
  });