How to use the private/co.path 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 / co / path.js View on Github external
// Copyright: ©2009-2010 Apple Inc. All rights reserved.
// License:   Licened under MIT license (see __preamble__.js)
// ==========================================================================
/*global process path sys assert libDir __filename */

process.mixin(require('../common'));

var Co = require('private/co');

// ..........................................................
// EXISTS
// 
// make sure Co.path.exists() includes an 'err' param to callback.

sys.puts('exists ' + __filename);
Co.path.exists(__filename, function(err, exists) {
  assert.equal(exists, true, 'should return true');
});

var path = Co.path.join('imaginary','file.foo');

sys.puts('exists ' + path);
Co.path.exists(path, function(err, exists) {
  assert.equal(exists, false, 'should return false');
});


// ..........................................................
// NORMALIZE
// 

// normalize should expand a ~
github seedjs / seed / tests / package / setup_teardown.js View on Github external
pkg.setup(function(err) {
      if (err) throw err; // shouldn't happen
      
      var filename = Co.path.join(installingDir, 'SETUP.out');
      Co.path.exists(filename, function(err, exists) {
        if (err) throw err;
        assert.equal(exists, true);
        Co.fs.readFile(filename, function(err, content) {
          if (err) throw err;
          assert.equal(content, 'setup '+installingDir); // should be cwd.
          return done(null, pkg);
        });
      });
    });
  },
github seedjs / seed / tests / co / path.js View on Github external
});

var path = Co.path.join('imaginary','file.foo');

sys.puts('exists ' + path);
Co.path.exists(path, function(err, exists) {
  assert.equal(exists, false, 'should return false');
});


// ..........................................................
// NORMALIZE
// 

// normalize should expand a ~
var expected = Co.path.join(process.env.HOME, 'foo');
assert.equal(Co.path.normalize('~/foo'), expected);
github seedjs / seed / tests / seed / collectMergedPluginInfo.js View on Github external
Ct.setup(function(t, done) {
  var path = Co.path.normalize(Co.path.join(__dirname, '..', '..', 'fixtures', 'loaders'));
  seed.openPackage(path, function(err, pkg) {
    if (err) return done(err);
    loadersPackage = pkg;
    done();
  });
});
github seedjs / seed / tests / package / setup_teardown.js View on Github external
var cleanup = Co.parallel(['SETUP.out', 'TEARDOWN.out'], function(filename, done) {
  filename = path.join(installingDir, filename);
  Co.path.exists(filename, function(err, exists) {
    if (err) return done(err);
    if (exists) return Co.fs.rm(filename, done);
    else done();
  });
});