├── test ├── fixtures │ ├── require.coffee │ ├── require.js │ ├── bower.json │ ├── composer.json │ ├── package.json │ ├── require.coffee.html │ ├── require.js.html │ ├── bower.json.html │ └── package.json.html ├── test_setup.js ├── test_require_coffee_remote.js ├── test_utils.js ├── test_require_coffee_local.js ├── test_manifest_bower_remote.js ├── test_manifest_bower_local.js ├── test_manifest_remote.js ├── test_manifest_local.js ├── test_require_remote.js └── test_require_local.js ├── .gitignore ├── .travis.yml ├── .editorconfig ├── .jshintrc ├── index.js ├── .jscs.json ├── README.md ├── lib ├── utils.js ├── manifest.js └── require.js ├── package.json └── gulpfile.js /test/fixtures/require.coffee: -------------------------------------------------------------------------------- 1 | require "path" 2 | lodash = require("lodash") -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | coverage/ 4 | npm-debug.log 5 | .DS_Store 6 | .idea 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | after_script: 5 | - npm run coveralls 6 | -------------------------------------------------------------------------------- /test/test_setup.js: -------------------------------------------------------------------------------- 1 | var registries = require('github-linker-registries'); 2 | 3 | before(function() { 4 | registries.npm = { 5 | lodash: 'https://github.com/lodash/lodash' 6 | }; 7 | }); 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 2 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false 22 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "unused": true, 11 | "boss": true, 12 | "eqnull": true, 13 | "node": true, 14 | "expr": true, 15 | "globals": { 16 | "describe" : false, 17 | "it" : false, 18 | "before" : false, 19 | "beforeEach" : false, 20 | "after" : false, 21 | "afterEach" : false, 22 | "window" : false 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/fixtures/require.js: -------------------------------------------------------------------------------- 1 | 2 | require('path'); 3 | require('lodash'); 4 | require('unknown-package-name'); 5 | require('./file.js'); 6 | require('./folder/file.js'); 7 | require('./file-or-folder'); 8 | require('../file.js'); 9 | require('../folder/file.js'); 10 | require('../file-or-folder'); 11 | require('../../file.js'); 12 | require('../../folder/file.js'); 13 | require('../../file-or-folder'); 14 | require('./'); 15 | require('..'); 16 | require('../'); 17 | require('../..'); 18 | require('../../'); 19 | require('.'); 20 | require('...'); 21 | require('/'); 22 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * github-linker-core 3 | * https://github.com/stefanbuck/github-linker 4 | * 5 | * Copyright (c) 2014 Stefan Buck 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | var utils = require('./lib/utils'); 12 | var manifest = require('./lib/manifest'); 13 | var reqr = require('./lib/require'); 14 | 15 | module.exports = function($, url, cb) { 16 | 17 | if ($('.github-linker').length > 0) { 18 | return cb(null); 19 | } 20 | 21 | if (utils.manifestType(url)) { 22 | manifest($, url, cb); 23 | } else if (utils.requireType(url)) { 24 | reqr($, url, cb); 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /.jscs.json: -------------------------------------------------------------------------------- 1 | { 2 | "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], 3 | "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], 4 | "disallowSpaceBeforeBinaryOperators": [",", ":"], 5 | "disallowSpaceAfterBinaryOperators": ["!"], 6 | "requireSpaceBeforeBinaryOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], 7 | "requireSpaceAfterBinaryOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], 8 | "disallowImplicitTypeConversion": ["string"], 9 | "disallowKeywords": ["with"], 10 | "disallowMultipleLineBreaks": true, 11 | "disallowKeywordsOnNewLine": ["else"], 12 | "disallowTrailingWhitespace": true, 13 | "requireLineFeedAtFileEnd": true, 14 | "validateIndentation": 2, 15 | "validateQuoteMarks": "'", 16 | "validateJSDoc": { 17 | "checkParamNames": true, 18 | "requireParamTypes": true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/fixtures/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "playground-repo", 3 | "description": "My personal playground", 4 | "version": "0.0.1", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "ignore": "", 8 | "keywords": [], 9 | "author": [ 10 | "Stefan Buck (http://stefanbuck.com)" 11 | ], 12 | "homepage": "https://github.com/stefanbuck/playground-repo", 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/stefanbuck/playground-repo" 16 | }, 17 | "dependencies": { 18 | "lodash": "2.4.1", 19 | "modernizr": "Modernizr/Modernizr", 20 | "backbone": "jashkenas/backbone#master", 21 | "jquery": "jquery/jquery#1.x-master", 22 | "unknown-package-name": "latest" 23 | }, 24 | "devDependencies": { 25 | "chai": "^1.9.1", 26 | "should": "^3.3.1" 27 | }, 28 | "resolutions": { 29 | "lodash": "2.1.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # github-linker-core 2 | [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image] [![Coverage Status][coveralls-image]][coveralls-url] 3 | 4 | > The [GitHub-Linker](https://github.com/stefanbuck/github-linker) core 5 | 6 | 7 | ## License 8 | 9 | Copyright (c) 2014 Stefan Buck. Licensed under the MIT license. 10 | 11 | 12 | 13 | [npm-url]: https://npmjs.org/package/github-linker-core 14 | [npm-image]: https://badge.fury.io/js/github-linker-core.svg 15 | [travis-url]: https://travis-ci.org/stefanbuck/github-linker-core 16 | [travis-image]: https://travis-ci.org/stefanbuck/github-linker-core.svg?branch=master 17 | [daviddm-url]: https://david-dm.org/stefanbuck/github-linker-core.svg?theme=shields.io 18 | [daviddm-image]: https://david-dm.org/stefanbuck/github-linker-core 19 | [coveralls-url]: https://coveralls.io/r/stefanbuck/github-linker-core 20 | [coveralls-image]: https://coveralls.io/repos/stefanbuck/github-linker-core/badge.png 21 | -------------------------------------------------------------------------------- /lib/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _ = require('lodash'); 4 | 5 | var getType = function(url, lookup) { 6 | 7 | var urlContains = function(indicator) { 8 | return url.indexOf(indicator) === url.length - indicator.length; 9 | }; 10 | 11 | return _.find(lookup, function(type, urlFragment) { 12 | return urlContains(urlFragment); 13 | }); 14 | }; 15 | 16 | var stripQuotes = function(jqElement) { 17 | return jqElement.html().replace(/"|'/g, ''); 18 | }; 19 | 20 | var manifestType = function(url) { 21 | var lookup = { 22 | '/package.json': 'npm', 23 | '/bower.json': 'bower', 24 | '/composer.json': 'composer' 25 | }; 26 | return getType(url, lookup); 27 | }; 28 | 29 | var requireType = function(url) { 30 | var lookup = { 31 | '.js': 'js', 32 | '.coffee': 'coffee' 33 | }; 34 | return getType(url, lookup); 35 | }; 36 | 37 | var showLoader = function($) { 38 | var $loaderContainer = $('.page-context-loader'); 39 | $loaderContainer.addClass('is-context-loading'); 40 | }; 41 | 42 | module.exports = { 43 | stripQuotes: stripQuotes, 44 | manifestType: manifestType, 45 | requireType: requireType, 46 | showLoader: showLoader 47 | }; 48 | -------------------------------------------------------------------------------- /test/fixtures/composer.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "name": "playground-repo", 4 | "description": "My personal playground", 5 | "version": "0.0.1", 6 | "type": "library", 7 | "keywords": [], 8 | "homepage": "https://github.com/stefanbuck/playground-repo", 9 | "time": "2014-09-19", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Stefan Buck", 14 | "email": "dev@stefanbuck.com", 15 | "homepage": "http://stefanbuck.com", 16 | "role": "Developer" 17 | } 18 | ], 19 | "support": { 20 | "email": "dev@stefanbuck.com", 21 | "irc": "irc://irc.freenode.org/composer" 22 | }, 23 | "require": { 24 | "php": ">=5.3.2", 25 | "laravel/framework": "~4.2", 26 | "unknown-package-name": "*" 27 | }, 28 | "require-dev": { 29 | "phpunit/phpunit": "~4.0", 30 | "doctrine/dbal": "~2.3" 31 | }, 32 | "conflict": {}, 33 | "replace": {}, 34 | "provide": {}, 35 | "suggest'": { 36 | "ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages", 37 | "doctrine/dbal": "Load information from the database about models for phpdocs (~2.3)" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "github-linker-core", 3 | "description": "The GitHub Linker core", 4 | "version": "0.0.1", 5 | "homepage": "https://github.com/stefanbuck/github-linker", 6 | "bugs": "https://github.com/stefanbuck/github-linker-core/issues", 7 | "license": "MIT", 8 | "main": "index.js", 9 | "author": { 10 | "name": "Stefan Buck", 11 | "email": "dev@stefanbuck.com", 12 | "url": "http://stefanbuck.com" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/stefanbuck/github-linker-core" 17 | }, 18 | "keywords": [], 19 | "dependencies": { 20 | "github-linker-registries": "^1.0.0", 21 | "jquery": "^2.1.1", 22 | "lodash": "2.4.1" 23 | }, 24 | "devDependencies": { 25 | "coveralls": "^2.11.1", 26 | "gulp": "^3.8.8", 27 | "gulp-bump": "^0.1.11", 28 | "gulp-istanbul": "^0.3.0", 29 | "gulp-jscs": "^1.1.2", 30 | "gulp-jshint": "^1.8.4", 31 | "gulp-load-plugins": "^0.6.0", 32 | "gulp-mocha": "^1.1.0", 33 | "gulp-plumber": "^0.6.5", 34 | "gulp-util": "^3.0.1", 35 | "jsdom": "^1.0.0-pre.6", 36 | "jshint-stylish": "^0.4.0", 37 | "should": "^4.0.4" 38 | }, 39 | "scripts": { 40 | "coveralls": "gulp test && cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", 41 | "test": "gulp test" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "playground-repo", 3 | "description": "My personal playground", 4 | "version": "0.0.1", 5 | "homepage": "https://github.com/stefanbuck/playground-repo", 6 | "bugs": "https://github.com/stefanbuck/playground-repo/issues", 7 | "license": "MIT", 8 | "main": "index.js", 9 | "author": { 10 | "name": "Stefan Buck", 11 | "email": "dev@stefanbuck.com", 12 | "url": "http://stefanbuck.com" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/stefanbuck/playground-repo" 17 | }, 18 | "keywords": [], 19 | "dependencies": { 20 | "lodash": "2.4.1", 21 | "request": "^2.40.0", 22 | "modernizr": "Modernizr/Modernizr", 23 | "backbone": "jashkenas/backbone#master", 24 | "jquery": "jquery/jquery#1.x-master", 25 | "unknown-package-name": "latest" 26 | }, 27 | "devDependencies": { 28 | "chai": "^1.9.1", 29 | "gulp": "^3.6.2" 30 | }, 31 | "optionalDependencies": { 32 | "should": "^3.3.1" 33 | }, 34 | "peerDependencies": { 35 | "yo": ">=1.0.0" 36 | }, 37 | "scripts": { 38 | "coveralls": "gulp test && cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", 39 | "test": "gulp test" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var gulp = require('gulp'); 4 | var plugins = require('gulp-load-plugins')(); 5 | 6 | var paths = { 7 | lint: ['./gulpfile.js', './lib/**/*.js', './index.js'], 8 | watch: ['./gulpfile.js', './lib/**/*.js', './index.js', './test/**/*.js', '!test/{temp,temp/**}'], 9 | tests: ['./test/**/*.js', '!test/{temp,temp/**}', '!test/fixtures/**'], 10 | source: ['./lib/**/*.js', './index.js'] 11 | }; 12 | 13 | gulp.task('lint', function () { 14 | return gulp.src(paths.lint) 15 | .pipe(plugins.jshint('.jshintrc')) 16 | .pipe(plugins.jscs()) 17 | .pipe(plugins.jshint.reporter('jshint-stylish')); 18 | }); 19 | 20 | gulp.task('istanbul', function (cb) { 21 | gulp.src(paths.source) 22 | .pipe(plugins.istanbul()) // Covering files 23 | .on('finish', function () { 24 | gulp.src(paths.tests) 25 | .pipe(plugins.plumber()) 26 | .pipe(plugins.mocha()) 27 | .pipe(plugins.istanbul.writeReports()) // Creating the reports after tests runned 28 | .on('finish', function() { 29 | process.chdir(__dirname); 30 | cb(); 31 | }); 32 | }); 33 | }); 34 | 35 | gulp.task('bump', ['test'], function () { 36 | var bumpType = plugins.util.env.type || 'patch'; // major.minor.patch 37 | 38 | return gulp.src(['./package.json']) 39 | .pipe(plugins.bump({ type: bumpType })) 40 | .pipe(gulp.dest('./')); 41 | }); 42 | 43 | gulp.task('watch', ['test'], function () { 44 | gulp.watch(paths.watch, ['test']); 45 | }); 46 | 47 | gulp.task('test', ['lint', 'istanbul']); 48 | 49 | gulp.task('release', ['bump']); 50 | 51 | gulp.task('default', ['test']); 52 | -------------------------------------------------------------------------------- /test/test_require_coffee_remote.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var githubLinkerCore = require('../'); 4 | var assert = require('should'); 5 | var _ = require('lodash'); 6 | var env = require('jsdom').env; 7 | 8 | describe('require.coffee', function() { 9 | 10 | describe('local', function() { 11 | var $, result; 12 | var url = 'https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/require.coffee'; 13 | 14 | before(function(done) { 15 | $ = result = null; 16 | 17 | env(url, function(err, window) { 18 | if (err) { 19 | return done(err); 20 | } 21 | $ = require('jquery')(window); 22 | 23 | githubLinkerCore($, url, function(err, _result) { 24 | if (err) { 25 | throw err; 26 | } 27 | result = _result; 28 | done(); 29 | }); 30 | }); 31 | }); 32 | 33 | it('found dependencies', function() { 34 | 35 | // TODO Evaluate why this doesn't work 36 | // result.should.have.length(2); 37 | 38 | result.length.should.equal(2); 39 | }); 40 | 41 | it('http://nodejs.org/api/path.html', function() { 42 | var item = _.findWhere(result, { 43 | name: 'path' 44 | }); 45 | 46 | (item.link === null).should.equal(false); 47 | item.link.should.equal('http://nodejs.org/api/path.html'); 48 | 49 | item.el.attr('href').should.equal('http://nodejs.org/api/path.html'); 50 | item.el.hasClass('tooltipped').should.be.false; 51 | }); 52 | 53 | it('https://github.com/lodash/lodash', function() { 54 | var item = _.findWhere(result, { 55 | name: 'lodash' 56 | }); 57 | 58 | (item.link === null).should.equal(false); 59 | item.link.should.equal('https://github.com/lodash/lodash'); 60 | 61 | item.el.attr('href').should.equal('https://github.com/lodash/lodash'); 62 | item.el.hasClass('tooltipped').should.be.false; 63 | }); 64 | 65 | }); 66 | }); 67 | -------------------------------------------------------------------------------- /test/test_utils.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../lib/utils'); 4 | var assert = require('should'); 5 | 6 | describe('utils', function() { 7 | 8 | describe('manifestType', function() { 9 | 10 | it('package.json', function() { 11 | utils.manifestType('https://github.com/stefanbuck/github-linker-core/blob/master/package.json').should.equal('npm'); 12 | }); 13 | 14 | it('bower.json', function() { 15 | utils.manifestType('https://github.com/stefanbuck/github-linker-core/blob/master/bower.json').should.equal('bower'); 16 | }); 17 | 18 | it('unknown.json', function() { 19 | (utils.manifestType('https://github.com/stefanbuck/github-linker-core/blob/master/unknown.json') === undefined).should.equal(true); 20 | }); 21 | }); 22 | 23 | describe('requireType', function() { 24 | 25 | it('file.js', function() { 26 | utils.requireType('https://github.com/stefanbuck/github-linker-core/blob/master/file.js').should.equal('js'); 27 | }); 28 | 29 | it('file.coffee', function() { 30 | utils.requireType('https://github.com/stefanbuck/github-linker-core/blob/master/file.coffee').should.equal('coffee'); 31 | }); 32 | 33 | it('file.txt', function() { 34 | (utils.requireType('https://github.com/stefanbuck/github-linker-core/blob/master/file.txt') === undefined).should.equal(true); 35 | }); 36 | }); 37 | 38 | describe('stripQuotes', function() { 39 | 40 | it('lodash', function() { 41 | utils.stripQuotes({html: function(){return 'lodash';}}).should.equal('lodash'); 42 | }); 43 | 44 | it('"lodash"', function() { 45 | utils.stripQuotes({html: function(){return '"lodash"';}}).should.equal('lodash'); 46 | }); 47 | 48 | it('\'lodash\'', function() { 49 | utils.stripQuotes({html: function(){return '\'lodash\'';}}).should.equal('lodash'); 50 | }); 51 | 52 | it('"lodash\'', function() { 53 | utils.stripQuotes({html: function(){return '"lodash\'';}}).should.equal('lodash'); 54 | }); 55 | 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /test/test_require_coffee_local.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var githubLinkerCore = require('../'); 4 | var fs = require('fs'); 5 | var path = require('path'); 6 | var assert = require('should'); 7 | var _ = require('lodash'); 8 | var env = require('jsdom').env; 9 | 10 | describe('require.coffee', function() { 11 | 12 | describe('local', function() { 13 | var $, result; 14 | var url = 'https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/require.coffee'; 15 | var file = path.resolve(__dirname, 'fixtures/require.coffee.html'); 16 | 17 | before(function(done) { 18 | $ = result = null; 19 | var html = fs.readFileSync(file, 'utf-8'); 20 | 21 | env(html, function(err, window) { 22 | if (err) { 23 | return done(err); 24 | } 25 | $ = require('jquery')(window); 26 | 27 | githubLinkerCore($, url, function(err, _result) { 28 | if (err) { 29 | throw err; 30 | } 31 | result = _result; 32 | done(); 33 | }); 34 | }); 35 | }); 36 | 37 | it('found dependencies', function() { 38 | 39 | // TODO Evaluate why this doesn't work 40 | // result.should.have.length(2); 41 | 42 | result.length.should.equal(2); 43 | }); 44 | 45 | it('http://nodejs.org/api/path.html', function() { 46 | var item = _.findWhere(result, { 47 | name: 'path' 48 | }); 49 | 50 | (item.link === null).should.equal(false); 51 | item.link.should.equal('http://nodejs.org/api/path.html'); 52 | 53 | item.el.attr('href').should.equal('http://nodejs.org/api/path.html'); 54 | item.el.hasClass('tooltipped').should.be.false; 55 | }); 56 | 57 | it('https://github.com/lodash/lodash', function() { 58 | var item = _.findWhere(result, { 59 | name: 'lodash' 60 | }); 61 | 62 | (item.link === null).should.equal(false); 63 | item.link.should.equal('https://github.com/lodash/lodash'); 64 | 65 | item.el.attr('href').should.equal('https://github.com/lodash/lodash'); 66 | item.el.hasClass('tooltipped').should.be.false; 67 | }); 68 | 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /lib/manifest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * github-linker-core 3 | * https://github.com/stefanbuck/github-linker 4 | * 5 | * Copyright (c) 2014 Stefan Buck 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | var registries = require('github-linker-registries'); 12 | var utils = require('./utils'); 13 | 14 | var SORRY = 'Sorry, there is no link for this package available'; 15 | 16 | var mainField = function($, type) { 17 | if (type === 'npm' || type === 'bower') { 18 | var $main = $('span.nt:contains("main")').next().next('[class^="s"]'); 19 | if ($main.length > 0) { 20 | var entryFile = utils.stripQuotes($main); 21 | if (entryFile) { 22 | $main.wrap(''); 23 | } 24 | } 25 | } 26 | }; 27 | 28 | var dependencieField = function($, type) { 29 | var $root, $row, $item, $version, name, version, link; 30 | var selectors = []; 31 | if (type === 'npm') { 32 | selectors = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']; 33 | } else if (type === 'bower') { 34 | selectors = ['dependencies', 'devDependencies', 'resolutions']; 35 | } else if (type === 'composer') { 36 | selectors = ['require', 'require-dev', 'conflict', 'replace', 'provide', 'suggest']; 37 | } 38 | 39 | var result = []; 40 | var registryList = registries[type]; 41 | 42 | selectors.forEach(function(selector) { 43 | $root = $('.nt:contains(\'' + selector + '\')'); 44 | 45 | if (!$root || $root.length === 0) { 46 | return; 47 | } 48 | 49 | $row = $root.closest('tr').next(); 50 | 51 | while ($row) { 52 | $item = $row.find('.nt'); 53 | $version = $row.find('.s2'); 54 | 55 | if (!$item.length || !$version.length) { 56 | return; 57 | } 58 | 59 | name = utils.stripQuotes($item); 60 | version = utils.stripQuotes($version); 61 | 62 | link = registryList[name]; 63 | 64 | if (version.split('/').length === 2) { 65 | link = 'https://github.com/' + version.replace('#', '/tree/'); 66 | 67 | } else if (!link) { 68 | 69 | if (type === 'npm') { 70 | link = 'https://www.npmjs.org/package/' + name; 71 | } else if (type === 'bower') { 72 | link = 'http://bower.io/search/?q=' + name; 73 | } 74 | } 75 | 76 | if (link) { 77 | $item = $item.wrap('').parent(); 78 | } else { 79 | $item.addClass('tooltipped tooltipped-e').attr('aria-label', SORRY); 80 | } 81 | 82 | result.push({ 83 | el: $item, 84 | version: version, 85 | name: name, 86 | link: link 87 | }); 88 | 89 | $row = $row.next(); 90 | } 91 | }); 92 | return result; 93 | }; 94 | 95 | module.exports = function($, url, cb) { 96 | 97 | var type = utils.manifestType(url); 98 | 99 | var result = dependencieField($, type); 100 | mainField($, type); 101 | 102 | cb(null, result); 103 | }; 104 | -------------------------------------------------------------------------------- /test/test_manifest_bower_remote.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var githubLinkerCore = require('../'); 4 | var fs = require('fs'); 5 | var path = require('path'); 6 | var assert = require('should'); 7 | var _ = require('lodash'); 8 | var env = require('jsdom').env; 9 | 10 | describe('manifest', function() { 11 | 12 | describe('bower.json', function() { 13 | 14 | describe('remote', function() { 15 | 16 | this.timeout(4000); 17 | 18 | var $, result; 19 | var url = 'https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/bower.json'; 20 | 21 | before(function(done) { 22 | $ = result = null; 23 | 24 | env(url, function(err, window) { 25 | if (err) { 26 | return done(err); 27 | } 28 | $ = require('jquery')(window); 29 | githubLinkerCore($, url, function(err, _result) { 30 | if (err) { 31 | throw err; 32 | } 33 | result = _result; 34 | done(); 35 | }); 36 | }); 37 | }); 38 | 39 | it('found dependencies', function() { 40 | 41 | // TODO Evaluate why this doesn't work 42 | // result.should.have.length(10); 43 | 44 | result.length.should.equal(8); 45 | }); 46 | 47 | it('check order', function() { 48 | result.length.should.equal(8); 49 | var pkgNames = ['lodash', 'modernizr', 'backbone', 'jquery', 'unknown-package-name', 'chai', 'should', 'lodash']; 50 | _.each(result, function(item, index) { 51 | item.name.should.equal( pkgNames[index] ); 52 | }); 53 | }); 54 | 55 | it('check link replacement', function() { 56 | $('a.github-linker').length.should.equal(9); 57 | }); 58 | 59 | it('link https://github.com/lodash/lodash', function() { 60 | var item = _.findWhere(result, { 61 | name: 'lodash' 62 | }); 63 | 64 | (item.link === null).should.equal(false); 65 | item.link.should.equal('https://github.com/lodash/lodash'); 66 | 67 | item.el.attr('href').should.equal('https://github.com/lodash/lodash'); 68 | item.el.hasClass('tooltipped').should.be.false; 69 | }); 70 | 71 | it('link https://github.com/Modernizr/Modernizr', function() { 72 | var item = _.findWhere(result, { 73 | name: 'modernizr' 74 | }); 75 | 76 | (item.link === null).should.equal(false); 77 | item.link.should.equal('https://github.com/Modernizr/Modernizr'); 78 | 79 | item.el.attr('href').should.equal('https://github.com/Modernizr/Modernizr'); 80 | item.el.hasClass('tooltipped').should.be.false; 81 | }); 82 | 83 | it('link https://github.com/jashkenas/backbone/tree/master', function() { 84 | var item = _.findWhere(result, { 85 | name: 'backbone' 86 | }); 87 | 88 | (item.link === null).should.equal(false); 89 | item.link.should.equal('https://github.com/jashkenas/backbone/tree/master'); 90 | 91 | item.el.attr('href').should.equal('https://github.com/jashkenas/backbone/tree/master'); 92 | item.el.hasClass('tooltipped').should.be.false; 93 | }); 94 | 95 | it('link https://github.com/jquery/jquery/tree/1.x-master', function() { 96 | var item = _.findWhere(result, { 97 | name: 'jquery' 98 | }); 99 | 100 | (item.link === null).should.equal(false); 101 | item.link.should.equal('https://github.com/jquery/jquery/tree/1.x-master'); 102 | 103 | item.el.attr('href').should.equal('https://github.com/jquery/jquery/tree/1.x-master'); 104 | item.el.hasClass('tooltipped').should.be.false; 105 | }); 106 | 107 | it('link http://bower.io/search/?q=unknown-package-name', function() { 108 | var item = _.findWhere(result, { 109 | name: 'unknown-package-name' 110 | }); 111 | 112 | (item.link === null).should.equal(false); 113 | item.link.should.equal('http://bower.io/search/?q=unknown-package-name'); 114 | }); 115 | 116 | it('entry file', function() { 117 | var mainFile = $('span.nt:contains("main")').parent().find('.github-linker').attr('href'); 118 | (!!mainFile).should.equal(true); 119 | mainFile.should.equal('index.js'); 120 | }); 121 | }); 122 | }); 123 | }); 124 | -------------------------------------------------------------------------------- /test/test_manifest_bower_local.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var githubLinkerCore = require('../'); 4 | var fs = require('fs'); 5 | var path = require('path'); 6 | var assert = require('should'); 7 | var _ = require('lodash'); 8 | var env = require('jsdom').env; 9 | 10 | describe('manifest', function() { 11 | 12 | describe('bower.json', function() { 13 | 14 | describe('local', function() { 15 | var $, result; 16 | var url = 'https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/bower.json'; 17 | var file = path.resolve(__dirname, 'fixtures/bower.json.html'); 18 | 19 | before(function(done) { 20 | $ = result = null; 21 | var html = fs.readFileSync(file, 'utf-8'); 22 | 23 | env(html, function(err, window) { 24 | if (err) { 25 | return done(err); 26 | } 27 | $ = require('jquery')(window); 28 | 29 | githubLinkerCore($, url, function(err, _result) { 30 | if (err) { 31 | throw err; 32 | } 33 | result = _result; 34 | done(); 35 | }); 36 | }); 37 | }); 38 | 39 | it('found dependencies', function() { 40 | 41 | // TODO Evaluate why this doesn't work 42 | // result.should.have.length(10); 43 | 44 | result.length.should.equal(8); 45 | }); 46 | 47 | it('check order', function() { 48 | result.length.should.equal(8); 49 | var pkgNames = ['lodash', 'modernizr', 'backbone', 'jquery', 'unknown-package-name', 'chai', 'should', 'lodash']; 50 | _.each(result, function(item, index) { 51 | item.name.should.equal( pkgNames[index] ); 52 | }); 53 | }); 54 | 55 | it('check link replacement', function() { 56 | $('a.github-linker').length.should.equal(9); 57 | }); 58 | 59 | it('link https://github.com/lodash/lodash', function() { 60 | var item = _.findWhere(result, { 61 | name: 'lodash' 62 | }); 63 | 64 | (item.link === null).should.equal(false); 65 | item.link.should.equal('https://github.com/lodash/lodash'); 66 | 67 | item.el.attr('href').should.equal('https://github.com/lodash/lodash'); 68 | item.el.hasClass('tooltipped').should.be.false; 69 | }); 70 | 71 | it('link https://github.com/Modernizr/Modernizr', function() { 72 | var item = _.findWhere(result, { 73 | name: 'modernizr' 74 | }); 75 | 76 | (item.link === null).should.equal(false); 77 | item.link.should.equal('https://github.com/Modernizr/Modernizr'); 78 | 79 | item.el.attr('href').should.equal('https://github.com/Modernizr/Modernizr'); 80 | item.el.hasClass('tooltipped').should.be.false; 81 | }); 82 | 83 | it('link https://github.com/jashkenas/backbone/tree/master', function() { 84 | var item = _.findWhere(result, { 85 | name: 'backbone' 86 | }); 87 | 88 | (item.link === null).should.equal(false); 89 | item.link.should.equal('https://github.com/jashkenas/backbone/tree/master'); 90 | 91 | item.el.attr('href').should.equal('https://github.com/jashkenas/backbone/tree/master'); 92 | item.el.hasClass('tooltipped').should.be.false; 93 | }); 94 | 95 | it('link https://github.com/jquery/jquery/tree/1.x-master', function() { 96 | var item = _.findWhere(result, { 97 | name: 'jquery' 98 | }); 99 | 100 | (item.link === null).should.equal(false); 101 | item.link.should.equal('https://github.com/jquery/jquery/tree/1.x-master'); 102 | 103 | item.el.attr('href').should.equal('https://github.com/jquery/jquery/tree/1.x-master'); 104 | item.el.hasClass('tooltipped').should.be.false; 105 | }); 106 | 107 | it('link http://bower.io/search/?q=unknown-package-name', function() { 108 | var item = _.findWhere(result, { 109 | name: 'unknown-package-name' 110 | }); 111 | 112 | (item.link === null).should.equal(false); 113 | item.link.should.equal('http://bower.io/search/?q=unknown-package-name'); 114 | }); 115 | 116 | it('entry file', function() { 117 | var mainFile = $('span.nt:contains("main")').parent().find('.github-linker').attr('href'); 118 | (!!mainFile).should.equal(true); 119 | mainFile.should.equal('index.js'); 120 | }); 121 | }); 122 | }); 123 | }); 124 | -------------------------------------------------------------------------------- /test/test_manifest_remote.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var githubLinkerCore = require('../'); 4 | var assert = require('should'); 5 | var _ = require('lodash'); 6 | var env = require('jsdom').env; 7 | 8 | describe('manifest', function() { 9 | 10 | describe('package.json', function() { 11 | 12 | describe('remote', function() { 13 | 14 | this.timeout(4000); 15 | 16 | var $, result; 17 | var url = 'https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/package.json'; 18 | 19 | before(function(done) { 20 | $ = result = null; 21 | 22 | env(url, function(err, window) { 23 | if (err) { 24 | return done(err); 25 | } 26 | $ = require('jquery')(window); 27 | githubLinkerCore($, url, function(err, _result) { 28 | if (err) { 29 | throw err; 30 | } 31 | result = _result; 32 | done(); 33 | }); 34 | }); 35 | }); 36 | 37 | it('found dependencies', function() { 38 | 39 | // TODO Evaluate why this doesn't work 40 | // result.should.have.length(10); 41 | 42 | result.length.should.equal(10); 43 | }); 44 | 45 | it('check order', function() { 46 | result.length.should.equal(10); 47 | var pkgNames = ['lodash', 'request', 'modernizr', 'backbone', 'jquery', 'unknown-package-name', 'chai', 'gulp', 'yo', 'should']; 48 | _.each(result, function(item, index) { 49 | item.name.should.equal( pkgNames[index] ); 50 | }); 51 | }); 52 | 53 | it('check link replacement', function() { 54 | $('a.github-linker').length.should.equal(11); 55 | }); 56 | 57 | it('link https://github.com/lodash/lodash', function() { 58 | var item = _.findWhere(result, { 59 | name: 'lodash' 60 | }); 61 | 62 | (item.link === null).should.equal(false); 63 | item.link.should.equal('https://github.com/lodash/lodash'); 64 | 65 | item.el.attr('href').should.equal('https://github.com/lodash/lodash'); 66 | item.el.hasClass('tooltipped').should.be.false; 67 | }); 68 | 69 | it('link https://www.npmjs.org/package/request', function() { 70 | var item = _.findWhere(result, { 71 | name: 'request' 72 | }); 73 | 74 | (item.link === null).should.equal(false); 75 | item.link.should.equal('https://www.npmjs.org/package/request'); 76 | 77 | item.el.attr('href').should.equal('https://www.npmjs.org/package/request'); 78 | item.el.hasClass('tooltipped').should.be.false; 79 | }); 80 | 81 | it('link https://github.com/Modernizr/Modernizr', function() { 82 | var item = _.findWhere(result, { 83 | name: 'modernizr' 84 | }); 85 | 86 | (item.link === null).should.equal(false); 87 | item.link.should.equal('https://github.com/Modernizr/Modernizr'); 88 | 89 | item.el.attr('href').should.equal('https://github.com/Modernizr/Modernizr'); 90 | item.el.hasClass('tooltipped').should.be.false; 91 | }); 92 | 93 | it('link https://github.com/jashkenas/backbone/tree/master', function() { 94 | var item = _.findWhere(result, { 95 | name: 'backbone' 96 | }); 97 | 98 | (item.link === null).should.equal(false); 99 | item.link.should.equal('https://github.com/jashkenas/backbone/tree/master'); 100 | 101 | item.el.attr('href').should.equal('https://github.com/jashkenas/backbone/tree/master'); 102 | item.el.hasClass('tooltipped').should.be.false; 103 | }); 104 | 105 | it('link https://github.com/jquery/jquery/tree/1.x-master', function() { 106 | var item = _.findWhere(result, { 107 | name: 'jquery' 108 | }); 109 | 110 | (item.link === null).should.equal(false); 111 | item.link.should.equal('https://github.com/jquery/jquery/tree/1.x-master'); 112 | 113 | item.el.attr('href').should.equal('https://github.com/jquery/jquery/tree/1.x-master'); 114 | item.el.hasClass('tooltipped').should.be.false; 115 | }); 116 | 117 | it('link https://www.npmjs.org/package/unknown-package-name', function() { 118 | var item = _.findWhere(result, { 119 | name: 'unknown-package-name' 120 | }); 121 | 122 | (item.link === null).should.equal(false); 123 | item.link.should.equal('https://www.npmjs.org/package/unknown-package-name'); 124 | 125 | item.el.attr('href').should.equal('https://www.npmjs.org/package/unknown-package-name'); 126 | item.el.hasClass('tooltipped').should.be.false; 127 | }); 128 | 129 | it('entry file', function() { 130 | var mainFile = $('span.nt:contains("main")').parent().find('.github-linker').attr('href'); 131 | (!!mainFile).should.equal(true); 132 | mainFile.should.equal('index.js'); 133 | }); 134 | }); 135 | }); 136 | }); 137 | -------------------------------------------------------------------------------- /lib/require.js: -------------------------------------------------------------------------------- 1 | /* 2 | * github-linker-core 3 | * https://github.com/stefanbuck/github-linker 4 | * 5 | * Copyright (c) 2014 Stefan Buck 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | var util = require('util'); 12 | var path = require('path'); 13 | var registries = require('github-linker-registries').npm; 14 | var utils = require('./utils'); 15 | 16 | // List of nodejs core modules (v0.11.13) 17 | // see: https://github.com/joyent/node/blob/master/lib/repl.js#L72 18 | var coreModules = ['assert', 'buffer', 'child_process', 'cluster', 'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'net', 'os', 'path', 'punycode', 'querystring', 'readline', 'stream', 'string_decoder', 'tls', 'tty', 'url', 'util', 'vm', 'zlib', 'smalloc', 'tracing']; 19 | var GITHUBCOM = 'https://github.com'; 20 | var NODEAPICOM = 'http://nodejs.org/api/%s.html'; 21 | var NPMAPICOM = 'https://www.npmjs.org/package/'; 22 | var SORRY = 'Can\'t resolve this require for you, sorry.'; 23 | var RESOLVE_INDICATOR = 'resolve:'; 24 | 25 | var isLocalPath = function(val) { 26 | if (val === '..') { 27 | return true; 28 | } 29 | var result = val.match(/^(\.\/|\.\.\/)/gm); 30 | if (result && result.length > 0) { 31 | return true; 32 | } 33 | return false; 34 | }; 35 | 36 | var getRequireLink = function(url, requireValue) { 37 | 38 | var link = ''; 39 | 40 | if (coreModules.indexOf(requireValue) !== -1 ) { 41 | 42 | link = util.format(NODEAPICOM, requireValue); 43 | 44 | } else if (registries[requireValue]) { 45 | 46 | link = registries[requireValue]; 47 | 48 | } else { 49 | if (isLocalPath(requireValue)) { 50 | var basePath = url.replace(GITHUBCOM, ''); 51 | link = path.resolve(path.dirname(basePath), requireValue); 52 | if (link.charAt(link.length - 1) === '/') { 53 | link = link.slice(0, -1); 54 | } 55 | link = RESOLVE_INDICATOR + GITHUBCOM + link; 56 | } else { 57 | link = RESOLVE_INDICATOR + NPMAPICOM + requireValue; 58 | } 59 | } 60 | 61 | return link; 62 | }; 63 | 64 | var attemptToLoadURL = function($, urls, cb) { 65 | var url = urls.shift(); 66 | $.ajax({ 67 | url: url, 68 | type: 'HEAD', 69 | timeout: 3000 70 | }).then(function() { 71 | cb(url); 72 | }).fail(function() { 73 | if (urls.length > 0) { 74 | attemptToLoadURL($, urls, cb); 75 | } else { 76 | cb(null); 77 | } 78 | }); 79 | }; 80 | 81 | var registerClickListener = function($, fileExtension) { 82 | fileExtension = '.' + fileExtension; 83 | 84 | $('body').on('click', 'a.github-linker', function(e) { 85 | utils.showLoader($); 86 | var $el = $(this); 87 | var link = $el.data('href'); 88 | 89 | if (link) { 90 | e.stopPropagation(); 91 | 92 | var urls = []; 93 | if (link.indexOf(GITHUBCOM) === 0) { 94 | if (path.extname(link)) { 95 | urls.push(link); 96 | } else { 97 | urls.push(link + fileExtension); 98 | } 99 | urls = urls.concat([ 100 | link + '/index' + fileExtension, 101 | link.replace('blob', 'tree') 102 | ]); 103 | } else { 104 | urls = link.split(','); 105 | } 106 | 107 | $el.addClass('tooltipped tooltipped-e').attr('aria-label', 'Loading ...'); 108 | attemptToLoadURL($, urls, function(link) { 109 | if (link) { 110 | window.location.href = link; 111 | } else { 112 | $el.attr('aria-label', SORRY); 113 | } 114 | }); 115 | } 116 | }); 117 | }; 118 | 119 | module.exports = function($, url, cb) { 120 | 121 | var $requires, $coffeeRequires, $item, name, link, resolveLink; 122 | var result = []; 123 | var type = utils.requireType(url); 124 | 125 | // Search for require dom elements 126 | $requires = $('span.nx').filter(function() { 127 | return $(this).text() === 'require'; 128 | }).next().next('[class^="s"]'); 129 | 130 | if (type === 'coffee') { 131 | $coffeeRequires = $('span.nx').filter(function() { 132 | return $(this).text() === 'require'; 133 | }).next('[class^="s"]'); 134 | $requires = $.merge($coffeeRequires, $requires); 135 | } 136 | 137 | $requires.each(function(index, item) { 138 | $item = $(item); 139 | 140 | name = utils.stripQuotes($item); 141 | link = getRequireLink(url, name); 142 | resolveLink = false; 143 | 144 | if ( link.indexOf(RESOLVE_INDICATOR) === 0) { 145 | link = link.replace(RESOLVE_INDICATOR, ''); 146 | resolveLink = true; 147 | $item = $item.wrap('').parent(); 148 | } else { 149 | $item = $item.wrap('').parent(); 150 | } 151 | 152 | result.push({ 153 | el: $item, 154 | name: name, 155 | link: link, 156 | resolveLink: resolveLink 157 | }); 158 | }); 159 | 160 | registerClickListener($, type); 161 | 162 | cb(null, result); 163 | }; 164 | -------------------------------------------------------------------------------- /test/test_manifest_local.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var githubLinkerCore = require('../'); 4 | var fs = require('fs'); 5 | var path = require('path'); 6 | var assert = require('should'); 7 | var _ = require('lodash'); 8 | var env = require('jsdom').env; 9 | 10 | describe('manifest', function() { 11 | 12 | describe('package.json', function() { 13 | 14 | describe('local', function() { 15 | var $, result; 16 | var url = 'https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/package.json'; 17 | var file = path.resolve(__dirname, 'fixtures/package.json.html'); 18 | 19 | before(function(done) { 20 | $ = result = null; 21 | var html = fs.readFileSync(file, 'utf-8'); 22 | 23 | env(html, function(err, window) { 24 | if (err) { 25 | return done(err); 26 | } 27 | $ = require('jquery')(window); 28 | 29 | githubLinkerCore($, url, function(err, _result) { 30 | if (err) { 31 | throw err; 32 | } 33 | result = _result; 34 | done(); 35 | }); 36 | }); 37 | }); 38 | 39 | it('found dependencies', function() { 40 | 41 | // TODO Evaluate why this doesn't work 42 | // result.should.have.length(10); 43 | 44 | result.length.should.equal(10); 45 | }); 46 | 47 | it('check order', function() { 48 | result.length.should.equal(10); 49 | var pkgNames = ['lodash', 'request', 'modernizr', 'backbone', 'jquery', 'unknown-package-name', 'chai', 'gulp', 'yo', 'should']; 50 | _.each(result, function(item, index) { 51 | item.name.should.equal( pkgNames[index] ); 52 | }); 53 | }); 54 | 55 | it('check link replacement', function() { 56 | $('a.github-linker').length.should.equal(11); 57 | }); 58 | 59 | it('link https://github.com/lodash/lodash', function() { 60 | var item = _.findWhere(result, { 61 | name: 'lodash' 62 | }); 63 | 64 | (item.link === null).should.equal(false); 65 | item.link.should.equal('https://github.com/lodash/lodash'); 66 | 67 | item.el.attr('href').should.equal('https://github.com/lodash/lodash'); 68 | item.el.hasClass('tooltipped').should.be.false; 69 | }); 70 | 71 | it('link https://www.npmjs.org/package/request', function() { 72 | var item = _.findWhere(result, { 73 | name: 'request' 74 | }); 75 | 76 | (item.link === null).should.equal(false); 77 | item.link.should.equal('https://www.npmjs.org/package/request'); 78 | 79 | item.el.attr('href').should.equal('https://www.npmjs.org/package/request'); 80 | item.el.hasClass('tooltipped').should.be.false; 81 | }); 82 | 83 | it('link https://github.com/Modernizr/Modernizr', function() { 84 | var item = _.findWhere(result, { 85 | name: 'modernizr' 86 | }); 87 | 88 | (item.link === null).should.equal(false); 89 | item.link.should.equal('https://github.com/Modernizr/Modernizr'); 90 | 91 | item.el.attr('href').should.equal('https://github.com/Modernizr/Modernizr'); 92 | item.el.hasClass('tooltipped').should.be.false; 93 | }); 94 | 95 | it('link https://github.com/jashkenas/backbone/tree/master', function() { 96 | var item = _.findWhere(result, { 97 | name: 'backbone' 98 | }); 99 | 100 | (item.link === null).should.equal(false); 101 | item.link.should.equal('https://github.com/jashkenas/backbone/tree/master'); 102 | 103 | item.el.attr('href').should.equal('https://github.com/jashkenas/backbone/tree/master'); 104 | item.el.hasClass('tooltipped').should.be.false; 105 | }); 106 | 107 | it('link https://github.com/jquery/jquery/tree/1.x-master', function() { 108 | var item = _.findWhere(result, { 109 | name: 'jquery' 110 | }); 111 | 112 | (item.link === null).should.equal(false); 113 | item.link.should.equal('https://github.com/jquery/jquery/tree/1.x-master'); 114 | 115 | item.el.attr('href').should.equal('https://github.com/jquery/jquery/tree/1.x-master'); 116 | item.el.hasClass('tooltipped').should.be.false; 117 | }); 118 | 119 | it('link https://www.npmjs.org/package/unknown-package-name', function() { 120 | var item = _.findWhere(result, { 121 | name: 'unknown-package-name' 122 | }); 123 | 124 | (item.link === null).should.equal(false); 125 | item.link.should.equal('https://www.npmjs.org/package/unknown-package-name'); 126 | 127 | item.el.attr('href').should.equal('https://www.npmjs.org/package/unknown-package-name'); 128 | item.el.hasClass('tooltipped').should.be.false; 129 | }); 130 | 131 | it('entry file', function() { 132 | var mainFile = $('span.nt:contains("main")').parent().find('.github-linker').attr('href'); 133 | (!!mainFile).should.equal(true); 134 | mainFile.should.equal('index.js'); 135 | }); 136 | }); 137 | }); 138 | }); 139 | -------------------------------------------------------------------------------- /test/test_require_remote.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var githubLinkerCore = require('../'); 4 | var assert = require('should'); 5 | var _ = require('lodash'); 6 | var env = require('jsdom').env; 7 | 8 | describe('require.js', function() { 9 | 10 | describe('remote', function() { 11 | var $, result; 12 | var url = 'https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/require.js'; 13 | 14 | before(function(done) { 15 | $ = result = null; 16 | 17 | env(url, function(err, window) { 18 | if (err) { 19 | return done(err); 20 | } 21 | $ = require('jquery')(window); 22 | 23 | githubLinkerCore($, url, function(err, _result) { 24 | if (err) { 25 | throw err; 26 | } 27 | result = _result; 28 | done(); 29 | }); 30 | }); 31 | }); 32 | 33 | it('found dependencies', function() { 34 | 35 | // TODO Evaluate why this doesn't work 36 | // result.should.have.length(20); 37 | 38 | result.length.should.equal(20); 39 | }); 40 | 41 | it('http://nodejs.org/api/path.html', function() { 42 | var item = _.findWhere(result, { 43 | name: 'path' 44 | }); 45 | 46 | (item.link === null).should.equal(false); 47 | item.link.should.equal('http://nodejs.org/api/path.html'); 48 | 49 | item.el.attr('href').should.equal('http://nodejs.org/api/path.html'); 50 | item.el.hasClass('tooltipped').should.be.false; 51 | }); 52 | 53 | it('https://github.com/lodash/lodash', function() { 54 | var item = _.findWhere(result, { 55 | name: 'lodash' 56 | }); 57 | 58 | (item.link === null).should.equal(false); 59 | item.link.should.equal('https://github.com/lodash/lodash'); 60 | 61 | item.el.attr('href').should.equal('https://github.com/lodash/lodash'); 62 | item.el.hasClass('tooltipped').should.be.false; 63 | }); 64 | 65 | it('unknown-package-name', function() { 66 | var item = _.findWhere(result, { 67 | name: 'unknown-package-name' 68 | }); 69 | 70 | (item.link === null).should.equal(false); 71 | item.link.should.equal('https://www.npmjs.org/package/unknown-package-name'); 72 | item.el.data('href').should.equal('https://www.npmjs.org/package/unknown-package-name'); 73 | item.el.hasClass('tooltipped').should.be.false; 74 | }); 75 | 76 | it('./file.js', function() { 77 | var item = _.findWhere(result, { 78 | name: './file.js' 79 | }); 80 | 81 | (item.link === null).should.equal(false); 82 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/file.js'); 83 | 84 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/file.js'); 85 | item.el.hasClass('tooltipped').should.be.false; 86 | }); 87 | 88 | it('./folder/file.js', function() { 89 | var item = _.findWhere(result, { 90 | name: './folder/file.js' 91 | }); 92 | 93 | (item.link === null).should.equal(false); 94 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/folder/file.js'); 95 | 96 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/folder/file.js'); 97 | item.el.hasClass('tooltipped').should.be.false; 98 | }); 99 | 100 | it('./file-or-folder', function() { 101 | var item = _.findWhere(result, { 102 | name: './file-or-folder' 103 | }); 104 | 105 | (item.link === null).should.equal(false); 106 | item.resolveLink.should.be.ok; 107 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/file-or-folder'); 108 | 109 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/file-or-folder'); 110 | item.el.hasClass('tooltipped').should.be.false; 111 | }); 112 | 113 | it('../file.js', function() { 114 | var item = _.findWhere(result, { 115 | name: '../file.js' 116 | }); 117 | 118 | (item.link === null).should.equal(false); 119 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/file.js'); 120 | 121 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/file.js'); 122 | item.el.hasClass('tooltipped').should.be.false; 123 | }); 124 | 125 | it('../folder/file.js', function() { 126 | var item = _.findWhere(result, { 127 | name: '../folder/file.js' 128 | }); 129 | 130 | (item.link === null).should.equal(false); 131 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/folder/file.js'); 132 | 133 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/folder/file.js'); 134 | item.el.hasClass('tooltipped').should.be.false; 135 | }); 136 | 137 | it('../file-or-folder', function() { 138 | var item = _.findWhere(result, { 139 | name: '../file-or-folder' 140 | }); 141 | 142 | (item.link === null).should.equal(false); 143 | item.resolveLink.should.be.ok; 144 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/file-or-folder'); 145 | 146 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/file-or-folder'); 147 | item.el.hasClass('tooltipped').should.be.false; 148 | }); 149 | 150 | it('../../file.js', function() { 151 | var item = _.findWhere(result, { 152 | name: '../../file.js' 153 | }); 154 | 155 | (item.link === null).should.equal(false); 156 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/file.js'); 157 | 158 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/file.js'); 159 | item.el.hasClass('tooltipped').should.be.false; 160 | }); 161 | 162 | it('../../folder/file.js', function() { 163 | var item = _.findWhere(result, { 164 | name: '../../folder/file.js' 165 | }); 166 | 167 | (item.link === null).should.equal(false); 168 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/folder/file.js'); 169 | 170 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/folder/file.js'); 171 | item.el.hasClass('tooltipped').should.be.false; 172 | }); 173 | 174 | it('../../file-or-folder', function() { 175 | var item = _.findWhere(result, { 176 | name: '../../file-or-folder' 177 | }); 178 | 179 | (item.link === null).should.equal(false); 180 | item.resolveLink.should.be.ok; 181 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/file-or-folder'); 182 | 183 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/file-or-folder'); 184 | item.el.hasClass('tooltipped').should.be.false; 185 | }); 186 | 187 | it('./', function() { 188 | var item = _.findWhere(result, { 189 | name: './' 190 | }); 191 | 192 | (item.link === null).should.equal(false); 193 | item.resolveLink.should.be.ok; 194 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures'); 195 | 196 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures'); 197 | item.el.hasClass('tooltipped').should.be.false; 198 | }); 199 | 200 | it('..', function() { 201 | var item = _.findWhere(result, { 202 | name: '..' 203 | }); 204 | 205 | (item.link === null).should.equal(false); 206 | item.resolveLink.should.be.ok; 207 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test'); 208 | 209 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test'); 210 | item.el.hasClass('tooltipped').should.be.false; 211 | }); 212 | 213 | it('../', function() { 214 | var item = _.findWhere(result, { 215 | name: '../' 216 | }); 217 | 218 | (item.link === null).should.equal(false); 219 | item.resolveLink.should.be.ok; 220 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test'); 221 | 222 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test'); 223 | item.el.hasClass('tooltipped').should.be.false; 224 | }); 225 | 226 | it('../..', function() { 227 | var item = _.findWhere(result, { 228 | name: '../..' 229 | }); 230 | 231 | (item.link === null).should.equal(false); 232 | item.resolveLink.should.be.ok; 233 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master'); 234 | 235 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master'); 236 | item.el.hasClass('tooltipped').should.be.false; 237 | }); 238 | 239 | it('../../', function() { 240 | var item = _.findWhere(result, { 241 | name: '../../' 242 | }); 243 | 244 | (item.link === null).should.equal(false); 245 | item.resolveLink.should.be.ok; 246 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master'); 247 | 248 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master'); 249 | item.el.hasClass('tooltipped').should.be.false; 250 | }); 251 | 252 | it.skip('.', function() { 253 | var item = _.findWhere(result, { 254 | name: '.' 255 | }); 256 | 257 | (item.link === null).should.equal(false); 258 | item.link.should.equal('tbd'); 259 | 260 | item.el.data('href').should.equal('tbd'); 261 | item.el.hasClass('tooltipped').should.be.false; 262 | }); 263 | 264 | it.skip('...', function() { 265 | var item = _.findWhere(result, { 266 | name: '...' 267 | }); 268 | 269 | (item.link === null).should.equal(false); 270 | item.link.should.equal('tbd'); 271 | 272 | item.el.data('href').should.equal('tbd'); 273 | item.el.hasClass('tooltipped').should.be.false; 274 | }); 275 | 276 | it.skip('/', function() { 277 | var item = _.findWhere(result, { 278 | name: '/' 279 | }); 280 | 281 | (item.link === null).should.equal(false); 282 | item.link.should.equal('tbd'); 283 | 284 | item.el.data('href').should.equal('tbd'); 285 | item.el.hasClass('tooltipped').should.be.false; 286 | }); 287 | 288 | }); 289 | }); 290 | -------------------------------------------------------------------------------- /test/test_require_local.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var githubLinkerCore = require('../'); 4 | var fs = require('fs'); 5 | var path = require('path'); 6 | var assert = require('should'); 7 | var _ = require('lodash'); 8 | var env = require('jsdom').env; 9 | 10 | describe('require.js', function() { 11 | 12 | describe('local', function() { 13 | var $, result; 14 | var url = 'https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/require.js'; 15 | var file = path.resolve(__dirname, 'fixtures/require.js.html'); 16 | 17 | before(function(done) { 18 | $ = result = null; 19 | var html = fs.readFileSync(file, 'utf-8'); 20 | 21 | env(html, function(err, window) { 22 | if (err) { 23 | return done(err); 24 | } 25 | $ = require('jquery')(window); 26 | 27 | githubLinkerCore($, url, function(err, _result) { 28 | if (err) { 29 | throw err; 30 | } 31 | result = _result; 32 | done(); 33 | }); 34 | }); 35 | }); 36 | 37 | it('found dependencies', function() { 38 | 39 | // TODO Evaluate why this doesn't work 40 | // result.should.have.length(20); 41 | 42 | result.length.should.equal(20); 43 | }); 44 | 45 | it('http://nodejs.org/api/path.html', function() { 46 | var item = _.findWhere(result, { 47 | name: 'path' 48 | }); 49 | 50 | (item.link === null).should.equal(false); 51 | item.link.should.equal('http://nodejs.org/api/path.html'); 52 | 53 | item.el.attr('href').should.equal('http://nodejs.org/api/path.html'); 54 | item.el.hasClass('tooltipped').should.be.false; 55 | }); 56 | 57 | it('https://github.com/lodash/lodash', function() { 58 | var item = _.findWhere(result, { 59 | name: 'lodash' 60 | }); 61 | 62 | (item.link === null).should.equal(false); 63 | item.link.should.equal('https://github.com/lodash/lodash'); 64 | 65 | item.el.attr('href').should.equal('https://github.com/lodash/lodash'); 66 | item.el.hasClass('tooltipped').should.be.false; 67 | }); 68 | 69 | it('unknown-package-name', function() { 70 | var item = _.findWhere(result, { 71 | name: 'unknown-package-name' 72 | }); 73 | 74 | (item.link === null).should.equal(false); 75 | item.link.should.equal('https://www.npmjs.org/package/unknown-package-name'); 76 | 77 | item.el.data('href').should.equal('https://www.npmjs.org/package/unknown-package-name'); 78 | item.el.hasClass('tooltipped').should.be.false; 79 | }); 80 | 81 | it('./file.js', function() { 82 | var item = _.findWhere(result, { 83 | name: './file.js' 84 | }); 85 | 86 | (item.link === null).should.equal(false); 87 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/file.js'); 88 | 89 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/file.js'); 90 | item.el.hasClass('tooltipped').should.be.false; 91 | }); 92 | 93 | it('./folder/file.js', function() { 94 | var item = _.findWhere(result, { 95 | name: './folder/file.js' 96 | }); 97 | 98 | (item.link === null).should.equal(false); 99 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/folder/file.js'); 100 | 101 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/folder/file.js'); 102 | item.el.hasClass('tooltipped').should.be.false; 103 | }); 104 | 105 | it('./file-or-folder', function() { 106 | var item = _.findWhere(result, { 107 | name: './file-or-folder' 108 | }); 109 | 110 | (item.link === null).should.equal(false); 111 | item.resolveLink.should.be.ok; 112 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/file-or-folder'); 113 | 114 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures/file-or-folder'); 115 | item.el.hasClass('tooltipped').should.be.false; 116 | }); 117 | 118 | it('../file.js', function() { 119 | var item = _.findWhere(result, { 120 | name: '../file.js' 121 | }); 122 | 123 | (item.link === null).should.equal(false); 124 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/file.js'); 125 | 126 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/file.js'); 127 | item.el.hasClass('tooltipped').should.be.false; 128 | }); 129 | 130 | it('../folder/file.js', function() { 131 | var item = _.findWhere(result, { 132 | name: '../folder/file.js' 133 | }); 134 | 135 | (item.link === null).should.equal(false); 136 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/folder/file.js'); 137 | 138 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/folder/file.js'); 139 | item.el.hasClass('tooltipped').should.be.false; 140 | }); 141 | 142 | it('../file-or-folder', function() { 143 | var item = _.findWhere(result, { 144 | name: '../file-or-folder' 145 | }); 146 | 147 | (item.link === null).should.equal(false); 148 | item.resolveLink.should.be.ok; 149 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/file-or-folder'); 150 | 151 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/file-or-folder'); 152 | item.el.hasClass('tooltipped').should.be.false; 153 | }); 154 | 155 | it('../../file.js', function() { 156 | var item = _.findWhere(result, { 157 | name: '../../file.js' 158 | }); 159 | 160 | (item.link === null).should.equal(false); 161 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/file.js'); 162 | 163 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/file.js'); 164 | item.el.hasClass('tooltipped').should.be.false; 165 | }); 166 | 167 | it('../../folder/file.js', function() { 168 | var item = _.findWhere(result, { 169 | name: '../../folder/file.js' 170 | }); 171 | 172 | (item.link === null).should.equal(false); 173 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/folder/file.js'); 174 | 175 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/folder/file.js'); 176 | item.el.hasClass('tooltipped').should.be.false; 177 | }); 178 | 179 | it('../../file-or-folder', function() { 180 | var item = _.findWhere(result, { 181 | name: '../../file-or-folder' 182 | }); 183 | 184 | (item.link === null).should.equal(false); 185 | item.resolveLink.should.be.ok; 186 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/file-or-folder'); 187 | 188 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/file-or-folder'); 189 | item.el.hasClass('tooltipped').should.be.false; 190 | }); 191 | 192 | it('./', function() { 193 | var item = _.findWhere(result, { 194 | name: './' 195 | }); 196 | 197 | (item.link === null).should.equal(false); 198 | item.resolveLink.should.be.ok; 199 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures'); 200 | 201 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test/fixtures'); 202 | item.el.hasClass('tooltipped').should.be.false; 203 | }); 204 | 205 | it('..', function() { 206 | var item = _.findWhere(result, { 207 | name: '..' 208 | }); 209 | 210 | (item.link === null).should.equal(false); 211 | item.resolveLink.should.be.ok; 212 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test'); 213 | 214 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test'); 215 | item.el.hasClass('tooltipped').should.be.false; 216 | }); 217 | 218 | it('../', function() { 219 | var item = _.findWhere(result, { 220 | name: '../' 221 | }); 222 | 223 | (item.link === null).should.equal(false); 224 | item.resolveLink.should.be.ok; 225 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test'); 226 | 227 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master/test'); 228 | item.el.hasClass('tooltipped').should.be.false; 229 | }); 230 | 231 | it('../..', function() { 232 | var item = _.findWhere(result, { 233 | name: '../..' 234 | }); 235 | 236 | (item.link === null).should.equal(false); 237 | item.resolveLink.should.be.ok; 238 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master'); 239 | 240 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master'); 241 | item.el.hasClass('tooltipped').should.be.false; 242 | }); 243 | 244 | it('../../', function() { 245 | var item = _.findWhere(result, { 246 | name: '../../' 247 | }); 248 | 249 | (item.link === null).should.equal(false); 250 | item.resolveLink.should.be.ok; 251 | item.link.should.equal('https://github.com/stefanbuck/github-linker-core/blob/master'); 252 | 253 | item.el.data('href').should.equal('https://github.com/stefanbuck/github-linker-core/blob/master'); 254 | item.el.hasClass('tooltipped').should.be.false; 255 | }); 256 | 257 | it.skip('.', function() { 258 | var item = _.findWhere(result, { 259 | name: '.' 260 | }); 261 | 262 | (item.link === null).should.equal(false); 263 | item.link.should.equal('tbd'); 264 | 265 | item.el.data('href').should.equal('tbd'); 266 | item.el.hasClass('tooltipped').should.be.false; 267 | }); 268 | 269 | it.skip('...', function() { 270 | var item = _.findWhere(result, { 271 | name: '...' 272 | }); 273 | 274 | (item.link === null).should.equal(false); 275 | item.link.should.equal('tbd'); 276 | 277 | item.el.data('href').should.equal('tbd'); 278 | item.el.hasClass('tooltipped').should.be.false; 279 | }); 280 | 281 | it.skip('/', function() { 282 | var item = _.findWhere(result, { 283 | name: '/' 284 | }); 285 | 286 | (item.link === null).should.equal(false); 287 | item.link.should.equal('tbd'); 288 | 289 | item.el.data('href').should.equal('tbd'); 290 | item.el.hasClass('tooltipped').should.be.false; 291 | }); 292 | 293 | it('resolve url', function() { 294 | var item = _.findWhere(result, { 295 | name: '../../file-or-folder' 296 | }); 297 | 298 | item.el.trigger('click'); 299 | }); 300 | 301 | }); 302 | }); 303 | -------------------------------------------------------------------------------- /test/fixtures/require.coffee.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | github-linker-core/require.coffee at master · stefanbuck/github-linker-core · GitHub 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Skip to content 61 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 |
77 | Sign up 78 | 79 |
80 | 81 | 95 | 96 | 110 | 111 |
112 |
113 | 114 | 115 | 116 |
117 |
118 |
119 | 120 |
121 |
122 |
123 | 124 | 153 | 154 |

155 | 156 | /github-linker-core 159 | 160 | 161 | 162 | 163 | 164 |

165 |
166 |
167 | 168 |
169 |
170 |
171 | 172 |
173 |
174 | 197 |
198 | 212 | 213 | 214 |
215 |
216 | 217 |
218 | 219 | 220 |
223 |

HTTPS clone URL

224 |
225 | 227 | 228 | 229 | 230 |
231 |
232 | 233 | 234 |
237 |

Subversion checkout URL

238 |
239 | 241 | 242 | 243 | 244 |
245 |
246 | 247 | 248 |

You can clone with 249 | HTTPS 250 | or Subversion. 251 | 252 | 253 | 254 |

255 | 256 | 257 | 258 | Clone in Desktop 259 | 260 | 261 | 262 | 267 | 268 | Download ZIP 269 | 270 |
271 |
272 | 273 |
274 | 275 | 276 | 277 | 278 | 279 | 280 |
281 | 282 |
283 | 288 | 289 | branch: 290 | master 291 | 292 | 293 | 347 |
348 | 349 |
350 | 355 | 356 | 357 | 363 |
364 | 365 | 368 |
369 | 370 | 371 |
372 |
373 | Stefan Buck 374 | 375 | 376 | 379 |
380 | 381 |
382 |

383 | 384 | 1 385 | contributor 386 | 387 |

388 | 389 |
390 | 399 |
400 | 401 |
402 |
403 |
404 |
405 | 2 lines (2 sloc) 406 | 407 | 0.041 kb 408 |
409 |
410 |
411 | Raw 412 | Blame 413 | History 414 |
415 | 416 | 421 | 422 | 423 | 424 | 426 | 427 | 429 | 430 | 431 |
432 |
433 | 434 |
435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 |
require "path"
lodash = require("lodash")
445 | 446 |
447 | 448 |
449 |
450 | 451 | Jump to Line 452 | 458 | 459 |
460 | 461 |
462 | 463 |
464 |
465 | 466 | 467 |
468 | 469 |
470 | 493 |
494 | 495 | 496 |
497 |
498 |
499 | 500 |
501 |
502 | 511 |
512 | 513 | 514 | 515 |
516 | 517 | 518 | Something went wrong with that request. Please try again. 519 |
520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | -------------------------------------------------------------------------------- /test/fixtures/require.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | github-linker-core/require.js at master · stefanbuck/github-linker-core · GitHub 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Skip to content 61 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 |
77 | Sign up 78 | 79 |
80 | 81 | 95 | 96 | 110 | 111 |
112 |
113 | 114 | 115 | 116 |
117 |
118 |
119 | 120 |
121 |
122 |
123 | 124 | 153 | 154 |

155 | 156 | /github-linker-core 159 | 160 | 161 | 162 | 163 | 164 |

165 |
166 |
167 | 168 |
169 |
170 |
171 | 172 |
173 |
174 | 197 |
198 | 212 | 213 | 214 |
215 |
216 | 217 |
218 | 219 | 220 |
223 |

HTTPS clone URL

224 |
225 | 227 | 228 | 229 | 230 |
231 |
232 | 233 | 234 |
237 |

Subversion checkout URL

238 |
239 | 241 | 242 | 243 | 244 |
245 |
246 | 247 | 248 |

You can clone with 249 | HTTPS 250 | or Subversion. 251 | 252 | 253 | 254 |

255 | 256 | 257 | 258 | Clone in Desktop 259 | 260 | 261 | 262 | 267 | 268 | Download ZIP 269 | 270 |
271 |
272 | 273 |
274 | 275 | 276 | 277 | 278 | 279 | 280 |
281 | 282 |
283 | 288 | 289 | branch: 290 | master 291 | 292 | 293 | 347 |
348 | 349 |
350 | 355 | 356 | 357 | 363 |
364 | 365 | 368 |
369 | 370 | 371 |
372 |
373 | Stefan Buck 374 | 375 | 376 | 379 |
380 | 381 |
382 |

383 | 384 | 1 385 | contributor 386 | 387 |

388 | 389 |
390 | 399 |
400 | 401 |
402 |
403 |
404 |
405 | 22 lines (20 sloc) 406 | 407 | 0.452 kb 408 |
409 |
410 |
411 | Raw 412 | Blame 413 | History 414 |
415 | 416 | 421 | 422 | 423 | 424 | 426 | 427 | 429 | 430 | 431 |
432 |
433 | 434 |
435 | 436 | 437 | 438 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 |
439 |
require('path');
require('lodash');
require('unknown-package-name');
require('./file.js');
require('./folder/file.js');
require('./file-or-folder');
require('../file.js');
require('../folder/file.js');
require('../file-or-folder');
require('../../file.js');
require('../../folder/file.js');
require('../../file-or-folder');
require('./');
require('..');
require('../');
require('../..');
require('../../');
require('.');
require('...');
require('/');
522 | 523 |
524 | 525 |
526 |
527 | 528 | Jump to Line 529 | 535 | 536 |
537 | 538 |
539 | 540 |
541 |
542 | 543 | 544 |
545 | 546 |
547 | 570 |
571 | 572 | 573 |
574 |
575 |
576 | 577 |
578 |
579 | 588 |
589 | 590 | 591 | 592 |
593 | 594 | 595 | Something went wrong with that request. Please try again. 596 |
597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | -------------------------------------------------------------------------------- /test/fixtures/bower.json.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | github-linker-core/bower.json at master · stefanbuck/github-linker-core · GitHub 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Skip to content 61 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 |
77 | Sign up 78 | 79 |
80 | 81 | 95 | 96 | 110 | 111 |
112 |
113 | 114 | 115 | 116 |
117 |
118 |
119 | 120 |
121 |
122 |
123 | 124 | 153 | 154 |

155 | 156 | /github-linker-core 159 | 160 | 161 | 162 | 163 | 164 |

165 |
166 |
167 | 168 |
169 |
170 |
171 | 172 |
173 |
174 | 197 |
198 | 212 | 213 | 214 |
215 |
216 | 217 |
218 | 219 | 220 |
223 |

HTTPS clone URL

224 |
225 | 227 | 228 | 229 | 230 |
231 |
232 | 233 | 234 |
237 |

Subversion checkout URL

238 |
239 | 241 | 242 | 243 | 244 |
245 |
246 | 247 | 248 |

You can clone with 249 | HTTPS 250 | or Subversion. 251 | 252 | 253 | 254 |

255 | 256 | 257 | 258 | Clone in Desktop 259 | 260 | 261 | 262 | 267 | 268 | Download ZIP 269 | 270 |
271 |
272 | 273 |
274 | 275 | 276 | 277 | 278 | 279 | 280 |
281 | 282 |
283 | 288 | 289 | branch: 290 | master 291 | 292 | 293 | 347 |
348 | 349 |
350 | 355 | 356 | 357 | 363 |
364 | 365 | 368 |
369 | 370 | 371 |
372 |
373 | Stefan Buck 374 | 375 | 376 |
377 | add bower fixture 378 |
379 |
380 | 381 |
382 |

383 | 384 | 1 385 | contributor 386 | 387 |

388 | 389 |
390 | 399 |
400 | 401 |
402 |
403 |
404 |
405 | 32 lines (31 sloc) 406 | 407 | 0.828 kb 408 |
409 |
410 |
411 | Raw 412 | Blame 413 | History 414 |
415 | 416 | 421 | 422 | 423 | 424 | 426 | 427 | 429 | 430 | 431 |
432 |
433 | 434 |
435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 |
{
"name": "playground-repo",
"description": "My personal playground",
"version": "0.0.1",
"main": "index.js",
"license": "MIT",
"ignore": "",
"keywords": [],
"author": [
"Stefan Buck <dev@stefanbuck.com> (http://stefanbuck.com)"
],
"homepage": "https://github.com/stefanbuck/playground-repo",
"repository": {
"type": "git",
"url": "https://github.com/stefanbuck/playground-repo"
},
"dependencies": {
"lodash": "2.4.1",
"modernizr": "Modernizr/Modernizr",
"backbone": "jashkenas/backbone#master",
"jquery": "jquery/jquery#1.x-master",
"unknown-package-name": "latest"
},
"devDependencies": {
"chai": "^1.9.1",
"should": "^3.3.1"
},
"resolutions": {
"lodash": "2.1.0"
}
}
561 | 562 |
563 | 564 |
565 |
566 | 567 | Jump to Line 568 | 574 | 575 |
576 | 577 |
578 | 579 |
580 |
581 | 582 | 583 |
584 | 585 |
586 | 609 |
610 | 611 | 612 |
613 |
614 |
615 | 616 |
617 |
618 | 627 |
628 | 629 | 630 | 631 |
632 | 633 | 634 | Something went wrong with that request. Please try again. 635 |
636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | -------------------------------------------------------------------------------- /test/fixtures/package.json.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | github-linker-core/package.json at master · stefanbuck/github-linker-core · GitHub 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Skip to content 61 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 |
77 | Sign up 78 | 79 |
80 | 81 | 95 | 96 | 110 | 111 |
112 |
113 | 114 | 115 | 116 |
117 |
118 |
119 | 120 |
121 |
122 |
123 | 124 | 153 | 154 |

155 | 156 | /github-linker-core 159 | 160 | 161 | 162 | 163 | 164 |

165 |
166 |
167 | 168 |
169 |
170 |
171 | 172 |
173 |
174 | 197 |
198 | 212 | 213 | 214 |
215 |
216 | 217 |
218 | 219 | 220 |
223 |

HTTPS clone URL

224 |
225 | 227 | 228 | 229 | 230 |
231 |
232 | 233 | 234 |
237 |

Subversion checkout URL

238 |
239 | 241 | 242 | 243 | 244 |
245 |
246 | 247 | 248 |

You can clone with 249 | HTTPS 250 | or Subversion. 251 | 252 | 253 | 254 |

255 | 256 | a href="http://mac.github.com" data-url="github-mac://openRepo/https://github.com/stefanbuck/github-linker-core" class="minibutton sidebar-button js-conduit-rewrite-url" title="Save stefanbuck/github-linker-core to your computer and use it in GitHub Desktop." aria-label="Save stefanbuck/github-linker-core to your computer and use it in GitHub Desktop."> 257 | 258 | Clone in Desktop 259 | 260 | 261 | 262 | 267 | 268 | Download ZIP 269 | 270 |
271 |
272 | 273 |
274 | 275 | 276 | 277 | 278 | 279 | 280 |
281 | 282 |
283 | 288 | 289 | branch: 290 | master 291 | 292 | 293 | 347 |
348 | 349 |
350 | 355 | 356 | 357 | 363 |
364 | 365 | 368 |
369 | 370 | 371 |
372 |
373 | Stefan Buck 374 | 375 | 376 |
377 | Create package.json 378 |
379 |
380 | 381 |
382 |

383 | 384 | 1 385 | contributor 386 | 387 |

388 | 389 |
390 | 399 |
400 | 401 |
402 |
403 |
404 |
405 | 42 lines (41 sloc) 406 | 407 | 1.173 kb 408 |
409 |
410 |
411 | Raw 412 | Blame 413 | History 414 |
415 | 416 | 421 | 422 | 423 | 424 | 426 | 427 | 429 | 430 | 431 |
432 |
433 | 434 |
435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 |
{
"name": "playground-repo",
"description": "My personal playground",
"version": "0.0.1",
"homepage": "https://github.com/stefanbuck/playground-repo",
"bugs": "https://github.com/stefanbuck/playground-repo/issues",
"license": "MIT",
"main": "index.js",
"author": {
"name": "Stefan Buck",
"email": "dev@stefanbuck.com",
"url": "http://stefanbuck.com"/td> 483 |
},
"repository": {
"type": "git",
"url": "https://github.com/stefanbuck/playground-repo"
},
"keywords": [],
"dependencies": {
"lodash": "2.4.1",
"request": "^2.40.0",
"modernizr": "Modernizr/Modernizr",
"backbone": "jashkenas/backbone#master",
"jquery": "jquery/jquery#1.x-master",
"unknown-package-name": "latest"
},
"devDependencies": {
"chai": "^1.9.1",
"gulp": "^3.6.2"
},
"optionalDependencies": {
"should": "^3.3.1"
},
"peerDependencies": {
"yo": ">=1.0.0"
},
"scripts": {
"coveralls": "gulp test && cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"test": "gulp test"
}
}
601 | 602 |
603 | 604 |
605 |
606 | 607 | Jump to Line 608 | 614 | 615 |
616 | 617 |
618 | 619 |
620 |
621 | 622 | 623 |
624 | 625 |
626 | 649 |
650 | 651 | 652 |
653 |
654 |
655 | 656 |
657 |
658 | 667 |
668 | 669 | 670 | 671 |
672 | 673 | 674 | Something went wrong with that request. Please try again. 675 |
676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | --------------------------------------------------------------------------------