"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/lib/links.js" (11 Apr 2017, 2752 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 (function() {
    2   var Command, Links, config, fs, path, tree, yargs,
    3     extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    4     hasProp = {}.hasOwnProperty;
    5 
    6   path = require('path');
    7 
    8   yargs = require('yargs');
    9 
   10   Command = require('./command');
   11 
   12   config = require('./apm');
   13 
   14   fs = require('./fs');
   15 
   16   tree = require('./tree');
   17 
   18   module.exports = Links = (function(superClass) {
   19     extend(Links, superClass);
   20 
   21     Links.commandNames = ['linked', 'links', 'lns'];
   22 
   23     function Links() {
   24       this.devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages');
   25       this.packagesPath = path.join(config.getAtomDirectory(), 'packages');
   26     }
   27 
   28     Links.prototype.parseOptions = function(argv) {
   29       var options;
   30       options = yargs(argv).wrap(100);
   31       options.usage("\nUsage: apm links\n\nList all of the symlinked atom packages in ~/.atom/packages and\n~/.atom/dev/packages.");
   32       return options.alias('h', 'help').describe('help', 'Print this usage message');
   33     };
   34 
   35     Links.prototype.getDevPackagePath = function(packageName) {
   36       return path.join(this.devPackagesPath, packageName);
   37     };
   38 
   39     Links.prototype.getPackagePath = function(packageName) {
   40       return path.join(this.packagesPath, packageName);
   41     };
   42 
   43     Links.prototype.getSymlinks = function(directoryPath) {
   44       var directory, i, len, ref, symlinkPath, symlinks;
   45       symlinks = [];
   46       ref = fs.list(directoryPath);
   47       for (i = 0, len = ref.length; i < len; i++) {
   48         directory = ref[i];
   49         symlinkPath = path.join(directoryPath, directory);
   50         if (fs.isSymbolicLinkSync(symlinkPath)) {
   51           symlinks.push(symlinkPath);
   52         }
   53       }
   54       return symlinks;
   55     };
   56 
   57     Links.prototype.logLinks = function(directoryPath) {
   58       var links;
   59       links = this.getSymlinks(directoryPath);
   60       console.log(directoryPath.cyan + " (" + links.length + ")");
   61       return tree(links, {
   62         emptyMessage: '(no links)'
   63       }, function(link) {
   64         var error, error1, realpath;
   65         try {
   66           realpath = fs.realpathSync(link);
   67         } catch (error1) {
   68           error = error1;
   69           realpath = '???'.red;
   70         }
   71         return (path.basename(link).yellow) + " -> " + realpath;
   72       });
   73     };
   74 
   75     Links.prototype.run = function(options) {
   76       var callback;
   77       callback = options.callback;
   78       this.logLinks(this.devPackagesPath);
   79       this.logLinks(this.packagesPath);
   80       return callback();
   81     };
   82 
   83     return Links;
   84 
   85   })(Command);
   86 
   87 }).call(this);