How to use the private/core.fs 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 / tests / helpers.js View on Github external
// ==========================================================================
// Project:   Seed - Flexible Package Manager
// Copyright: ©2009-2010 Apple Inc. All rights reserved.
// License:   Licened under MIT license (see __preamble__.js)
// ==========================================================================


var core = require('private/core');

// exports some core API
exports.FIXTURES_ROOT = core.path.join(core.SEED_ROOT, 'fixtures');
exports.path = core.path;
exports.fs   = core.fs;
exports.tiki = core.tiki;

// make a unit tmpdir just for this guy
if (!core.TMPDIR || core.TMPDIR.length===0) throw "no platform.TMPDIR";
exports.TMPDIR = core.path.join(core.TMPDIR, core.uuid());

// stage a fixture by copying it to the tmp directory.  
exports.stage = function(fixturePath) {
  var path = core.path.join.apply(core.path, arguments);

  var src = core.path.join(exports.FIXTURES_ROOT, path);
  var dst = core.path.join(exports.TMPDIR, path);
  
  if (!core.fs.exists(src)) throw 'stage fixtures '+path+' not found';
  core.fs.mkdir_p(core.path.dirname(dst), core.fs.A_RWX);
  core.fs.cp_r(src, dst);
github seedjs / seed / lib / remote.js View on Github external
CORE.iter.chain(function(done) {
      CORE.fs.mkdir_p(CORE.path.dirname(path), 511, function(err) {
        if (err) return done(err);
        CORE.fs.open(path, 'w+' , 511, done);
      });
      
    // next, open a connection to the server and download...
    }, function(fd, done) {
github seedjs / seed / lib / commands / fork.js View on Github external
})(function(err) {
      if (err) return done(err);
      CORE.fs.mkdir_p(dstRoot, CORE.fs.A_RWX);
      CORE.verbose("Cloning "+repo.url+" to "+dstPath);
        
      var cmd = 'cd '+CORE.path.dirname(dstPath)+'; git clone '+repo.url+' '+CORE.path.basename(dstPath);
        
      // we need to use ChildProcess so we can stream output as it 
      // comes
      CORE.fs.exec(cmd, true, function(err) {
        if (err) return done(err);
        CORE.println("Forked package "+packageId);
        return done();
      });
    });
  };
github seedjs / seed / lib / commands / freeze.js View on Github external
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');
        }
        
        CORE.verbose("Removing existing package at "+dstPath);
        CORE.fs.rm_r(dstPath);
      }

      // copy package into target
      CORE.fs.mkdir_p(dstRoot, CORE.fs.A_RWX);
      CORE.verbose("Copying "+pkg.path+" to "+dstPath);
      pkg.copy(dstPath, function(err) {
        if (err) return done(err);
        CORE.println("Froze package "+packageId);
        return done();
      });
      
    })(done);
  };
github seedjs / seed / lib / commands / fork.js View on Github external
})(function(err) {
      if (err) return done(err);
      CORE.fs.mkdir_p(dstRoot, CORE.fs.A_RWX);
      CORE.verbose("Cloning "+repo.url+" to "+dstPath);
        
      var cmd = 'cd '+CORE.path.dirname(dstPath)+'; git clone '+repo.url+' '+CORE.path.basename(dstPath);
        
      // we need to use ChildProcess so we can stream output as it 
      // comes
      CORE.fs.exec(cmd, true, function(err) {
        if (err) return done(err);
        CORE.println("Forked package "+packageId);
        return done();
      });
    });
  };
github seedjs / seed / lib / remote.js View on Github external
upload: function(method, url, path, headers, done) {

    if ('function' === typeof headers) {
      done = headers;
      headers = undefined;
    }

    var remote = this;
    
    // open file for reading
    CORE.fs.stat(path, function(err, stat) {
      if (err) return done(err);
      var len = stat.size;
      CORE.verbose("Uploading " + len + " bytes");
      
      CORE.fs.open(path, 'r', 0, function(err, fd) {
        if (err) return done(err);

        var client = HTTP.createClient(remote.port, remote.hostname);
        
        if (!headers) headers = [];
        //headers.push(['Transfer-Encoding', 'chunked']);
        headers.push(['Content-Length', len]);

        var hostHeader = remote.hostname;
        if (Number(remote.port) !== 80) hostHeader = hostHeader+':'+remote.port;
        headers.push(['Host', hostHeader]);
github seedjs / seed / tests / helpers.js View on Github external
exports.unstage = function(stagingPath) {
  var path = core.path.join.apply(core.path, arguments);
  var dst = core.path.join(exports.TMPDIR, path);
  if (core.fs.exists(dst)) core.fs.rm_r(dst);
};
github seedjs / seed / lib / commands / unfreeze.js View on Github external
isUnderSourceControl = SRC_DIRS.some(function(dirname) {
      return CORE.fs.exists(CORE.path.join(pkg.path, dirname));
    });
github seedjs / seed / lib / commands / freeze.js View on Github external
var mkdstRoot = CORE.once(function(done) {
    CORE.fs.mkdir_p(dstRoot, 511, done);
  });
github seedjs / seed / lib / remote.js View on Github external
function writeChunk() {
        if (writing) return;
        var chunk = queue.shift();
        if (chunk !== undefined) {
          writing = true;
          CORE.fs.write(fd, chunk, null, 'binary', function(err) {
            if (err) return done(err);
            writing = false;
            endWrite();
            writeChunk();
          });
        }
      }