{"action":"created","comment":{"url":"https://api.github.com/repos/tapio/live-server/pulls/comments/43990129","id":43990129,"diff_hunk":"@@ -59,6 +60,13 @@ for (var i = process.argv.length - 1; i >= 2; --i) {\n \t\topts.logLevel = 0;\n \t\tprocess.argv.splice(i, 1);\n \t}\n+\telse if (arg.indexOf(\"--mount=\") > -1) {\n+\t\t// e.g. \"--mount=/components:./node_modules\" will be ['/components', '<process.cwd()>/node_modules']\n+\t\tvar mountRule = arg.substring(8).split(\":\");\n+\t\tmountRule[1] = path.resolve(process.cwd(), mountRule[1]); ","path":"live-server.js","position":15,"original_position":15,"commit_id":"072c6b87a540ebabbc5734c7c1c1ad40524db215","original_commit_id":"072c6b87a540ebabbc5734c7c1c1ad40524db215","user":{"login":"pmentz","id":10348960,"avatar_url":"https://avatars.githubusercontent.com/u/10348960?v=3","gravatar_id":"","url":"https://api.github.com/users/pmentz","html_url":"https://github.com/pmentz","followers_url":"https://api.github.com/users/pmentz/followers","following_url":"https://api.github.com/users/pmentz/following{/other_user}","gists_url":"https://api.github.com/users/pmentz/gists{/gist_id}","starred_url":"https://api.github.com/users/pmentz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmentz/subscriptions","organizations_url":"https://api.github.com/users/pmentz/orgs","repos_url":"https://api.github.com/users/pmentz/repos","events_url":"https://api.github.com/users/pmentz/events{/privacy}","received_events_url":"https://api.github.com/users/pmentz/received_events","type":"User","site_admin":false},"body":"Hehe, nice you found this, I was thinking about the right way for quite a time. I decided to go with this for the following reason. Imagine your project structure is\r\n```\r\n* my_proj\r\n   * node_modules\r\n   * source\r\n```\r\nAnd I want the live-server to serve the files in *source*. My command line is located in the root folder of the project. In this case I think it is more intuitive to address the directories relatively to my current position and not to the future position.\r\n```\r\nmy_proj$ live-server --mount=/components:node_modules source\r\n```\r\nvs\r\n```\r\nmy_proj$ live-server --mount=/components:../node_modules source\r\n```\r\nIn addition I can use the path completion of my shell to resolve the paths, because they are relative to my position.","created_at":"2015-11-05T09:13:49Z","updated_at":"2015-11-05T09:13:49Z","html_url":"https://github.com/tapio/live-server/pull/65#discussion_r43990129","pull_request_url":"https://api.github.com/repos/tapio/live-server/pulls/65","_links":{"self":{"href":"https://api.github.com/repos/tapio/live-server/pulls/comments/43990129"},"html":{"href":"https://github.com/tapio/live-server/pull/65#discussion_r43990129"},"pull_request":{"href":"https://api.github.com/repos/tapio/live-server/pulls/65"}}},"pull_request":{"url":"https://api.github.com/repos/tapio/live-server/pulls/65","id":49753454,"html_url":"https://github.com/tapio/live-server/pull/65","diff_url":"https://github.com/tapio/live-server/pull/65.diff","patch_url":"https://github.com/tapio/live-server/pull/65.patch","issue_url":"https://api.github.com/repos/tapio/live-server/issues/65","number":65,"state":"open","locked":false,"title":"Add --mount to serve files from alternate path.","user":{"login":"pmentz","id":10348960,"avatar_url":"https://avatars.githubusercontent.com/u/10348960?v=3","gravatar_id":"","url":"https://api.github.com/users/pmentz","html_url":"https://github.com/pmentz","followers_url":"https://api.github.com/users/pmentz/followers","following_url":"https://api.github.com/users/pmentz/following{/other_user}","gists_url":"https://api.github.com/users/pmentz/gists{/gist_id}","starred_url":"https://api.github.com/users/pmentz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmentz/subscriptions","organizations_url":"https://api.github.com/users/pmentz/orgs","repos_url":"https://api.github.com/users/pmentz/repos","events_url":"https://api.github.com/users/pmentz/events{/privacy}","received_events_url":"https://api.github.com/users/pmentz/received_events","type":"User","site_admin":false},"body":"Heya.\r\n\r\nI think source tells more than words, so I implemented my proposal. Nevertheless some words. This PR allows to mount folders into the hosted web application. For me this is useful for 2 reasons:\r\n\r\n1. I don't like to address artifacts under ../node_modules, as they should be hosted under /components in my target environment and I feel unwell to explicitly leave the source/root folder.\r\n2. I like typescript or coffee script files to be transpiled into a separate build directory but they should be hosted at the location where the sources were.\r\n\r\nWith this PR I am able to start the live-server with\r\n```\r\nlive-server --mount=/components:node_modules --mount=/:build source\r\n```\r\nMaybe nasty configuration, but simple. The `--mount=` indicates the configuration parameter, the `:` is used to separate the route from the folder.\r\nIt is also possible to configure it as node modules as an array of arrays:\r\n```JavaScript\r\n{\r\n  mount: [['/components', 'node_modules'], ['/', 'build']]\r\n}\r\n```\r\nThe reason why I decided to use arrays instead of an object is, that it may be possible to define a route for multiple folders. Maybe there are better possibilities for this one, but I wanted to keep it simple unless I don't know if you even accept the idea.\r\n\r\nThe implementation is quite simple, I just reuse the existing staticServer implementation and just used `paths` instead of `path` for watchr.\r\n\r\nBTW: Don't know how to describe that --mount can be used multiple times in the Usage example. Maybe it's not necessary at all.\r\n\r\nKeep in mind, that this is just a proposal. I am not sure if it matches will all the paradigms and ideas of the module, especially regarding the simplicity. That's up to you to decide. ;)","created_at":"2015-11-04T22:11:45Z","updated_at":"2015-11-05T09:13:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6ac4254c2110ffa97546fbe367804aad4f8babd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tapio/live-server/pulls/65/commits","review_comments_url":"https://api.github.com/repos/tapio/live-server/pulls/65/comments","review_comment_url":"https://api.github.com/repos/tapio/live-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tapio/live-server/issues/65/comments","statuses_url":"https://api.github.com/repos/tapio/live-server/statuses/072c6b87a540ebabbc5734c7c1c1ad40524db215","head":{"label":"pmentz:master","ref":"master","sha":"072c6b87a540ebabbc5734c7c1c1ad40524db215","user":{"login":"pmentz","id":10348960,"avatar_url":"https://avatars.githubusercontent.com/u/10348960?v=3","gravatar_id":"","url":"https://api.github.com/users/pmentz","html_url":"https://github.com/pmentz","followers_url":"https://api.github.com/users/pmentz/followers","following_url":"https://api.github.com/users/pmentz/following{/other_user}","gists_url":"https://api.github.com/users/pmentz/gists{/gist_id}","starred_url":"https://api.github.com/users/pmentz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmentz/subscriptions","organizations_url":"https://api.github.com/users/pmentz/orgs","repos_url":"https://api.github.com/users/pmentz/repos","events_url":"https://api.github.com/users/pmentz/events{/privacy}","received_events_url":"https://api.github.com/users/pmentz/received_events","type":"User","site_admin":false},"repo":{"id":45564848,"name":"live-server","full_name":"pmentz/live-server","owner":{"login":"pmentz","id":10348960,"avatar_url":"https://avatars.githubusercontent.com/u/10348960?v=3","gravatar_id":"","url":"https://api.github.com/users/pmentz","html_url":"https://github.com/pmentz","followers_url":"https://api.github.com/users/pmentz/followers","following_url":"https://api.github.com/users/pmentz/following{/other_user}","gists_url":"https://api.github.com/users/pmentz/gists{/gist_id}","starred_url":"https://api.github.com/users/pmentz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmentz/subscriptions","organizations_url":"https://api.github.com/users/pmentz/orgs","repos_url":"https://api.github.com/users/pmentz/repos","events_url":"https://api.github.com/users/pmentz/events{/privacy}","received_events_url":"https://api.github.com/users/pmentz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pmentz/live-server","description":"A simple development http server with live reload capability.","fork":true,"url":"https://api.github.com/repos/pmentz/live-server","forks_url":"https://api.github.com/repos/pmentz/live-server/forks","keys_url":"https://api.github.com/repos/pmentz/live-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pmentz/live-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pmentz/live-server/teams","hooks_url":"https://api.github.com/repos/pmentz/live-server/hooks","issue_events_url":"https://api.github.com/repos/pmentz/live-server/issues/events{/number}","events_url":"https://api.github.com/repos/pmentz/live-server/events","assignees_url":"https://api.github.com/repos/pmentz/live-server/assignees{/user}","branches_url":"https://api.github.com/repos/pmentz/live-server/branches{/branch}","tags_url":"https://api.github.com/repos/pmentz/live-server/tags","blobs_url":"https://api.github.com/repos/pmentz/live-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pmentz/live-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pmentz/live-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/pmentz/live-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pmentz/live-server/statuses/{sha}","languages_url":"https://api.github.com/repos/pmentz/live-server/languages","stargazers_url":"https://api.github.com/repos/pmentz/live-server/stargazers","contributors_url":"https://api.github.com/repos/pmentz/live-server/contributors","subscribers_url":"https://api.github.com/repos/pmentz/live-server/subscribers","subscription_url":"https://api.github.com/repos/pmentz/live-server/subscription","commits_url":"https://api.github.com/repos/pmentz/live-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/pmentz/live-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/pmentz/live-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/pmentz/live-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/pmentz/live-server/contents/{+path}","compare_url":"https://api.github.com/repos/pmentz/live-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pmentz/live-server/merges","archive_url":"https://api.github.com/repos/pmentz/live-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pmentz/live-server/downloads","issues_url":"https://api.github.com/repos/pmentz/live-server/issues{/number}","pulls_url":"https://api.github.com/repos/pmentz/live-server/pulls{/number}","milestones_url":"https://api.github.com/repos/pmentz/live-server/milestones{/number}","notifications_url":"https://api.github.com/repos/pmentz/live-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pmentz/live-server/labels{/name}","releases_url":"https://api.github.com/repos/pmentz/live-server/releases{/id}","created_at":"2015-11-04T20:15:36Z","updated_at":"2015-11-04T20:15:37Z","pushed_at":"2015-11-04T21:40:01Z","git_url":"git://github.com/pmentz/live-server.git","ssh_url":"git@github.com:pmentz/live-server.git","clone_url":"https://github.com/pmentz/live-server.git","svn_url":"https://github.com/pmentz/live-server","homepage":null,"size":509,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tapio:master","ref":"master","sha":"4884f342dc48b4b093a9571bdca03bf664a6160a","user":{"login":"tapio","id":83229,"avatar_url":"https://avatars.githubusercontent.com/u/83229?v=3","gravatar_id":"","url":"https://api.github.com/users/tapio","html_url":"https://github.com/tapio","followers_url":"https://api.github.com/users/tapio/followers","following_url":"https://api.github.com/users/tapio/following{/other_user}","gists_url":"https://api.github.com/users/tapio/gists{/gist_id}","starred_url":"https://api.github.com/users/tapio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tapio/subscriptions","organizations_url":"https://api.github.com/users/tapio/orgs","repos_url":"https://api.github.com/users/tapio/repos","events_url":"https://api.github.com/users/tapio/events{/privacy}","received_events_url":"https://api.github.com/users/tapio/received_events","type":"User","site_admin":false},"repo":{"id":7166430,"name":"live-server","full_name":"tapio/live-server","owner":{"login":"tapio","id":83229,"avatar_url":"https://avatars.githubusercontent.com/u/83229?v=3","gravatar_id":"","url":"https://api.github.com/users/tapio","html_url":"https://github.com/tapio","followers_url":"https://api.github.com/users/tapio/followers","following_url":"https://api.github.com/users/tapio/following{/other_user}","gists_url":"https://api.github.com/users/tapio/gists{/gist_id}","starred_url":"https://api.github.com/users/tapio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tapio/subscriptions","organizations_url":"https://api.github.com/users/tapio/orgs","repos_url":"https://api.github.com/users/tapio/repos","events_url":"https://api.github.com/users/tapio/events{/privacy}","received_events_url":"https://api.github.com/users/tapio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tapio/live-server","description":"A simple development http server with live reload capability.","fork":false,"url":"https://api.github.com/repos/tapio/live-server","forks_url":"https://api.github.com/repos/tapio/live-server/forks","keys_url":"https://api.github.com/repos/tapio/live-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tapio/live-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tapio/live-server/teams","hooks_url":"https://api.github.com/repos/tapio/live-server/hooks","issue_events_url":"https://api.github.com/repos/tapio/live-server/issues/events{/number}","events_url":"https://api.github.com/repos/tapio/live-server/events","assignees_url":"https://api.github.com/repos/tapio/live-server/assignees{/user}","branches_url":"https://api.github.com/repos/tapio/live-server/branches{/branch}","tags_url":"https://api.github.com/repos/tapio/live-server/tags","blobs_url":"https://api.github.com/repos/tapio/live-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tapio/live-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tapio/live-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/tapio/live-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tapio/live-server/statuses/{sha}","languages_url":"https://api.github.com/repos/tapio/live-server/languages","stargazers_url":"https://api.github.com/repos/tapio/live-server/stargazers","contributors_url":"https://api.github.com/repos/tapio/live-server/contributors","subscribers_url":"https://api.github.com/repos/tapio/live-server/subscribers","subscription_url":"https://api.github.com/repos/tapio/live-server/subscription","commits_url":"https://api.github.com/repos/tapio/live-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/tapio/live-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/tapio/live-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/tapio/live-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/tapio/live-server/contents/{+path}","compare_url":"https://api.github.com/repos/tapio/live-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tapio/live-server/merges","archive_url":"https://api.github.com/repos/tapio/live-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tapio/live-server/downloads","issues_url":"https://api.github.com/repos/tapio/live-server/issues{/number}","pulls_url":"https://api.github.com/repos/tapio/live-server/pulls{/number}","milestones_url":"https://api.github.com/repos/tapio/live-server/milestones{/number}","notifications_url":"https://api.github.com/repos/tapio/live-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tapio/live-server/labels{/name}","releases_url":"https://api.github.com/repos/tapio/live-server/releases{/id}","created_at":"2012-12-14T14:14:12Z","updated_at":"2015-11-05T04:38:46Z","pushed_at":"2015-11-04T22:11:45Z","git_url":"git://github.com/tapio/live-server.git","ssh_url":"git@github.com:tapio/live-server.git","clone_url":"https://github.com/tapio/live-server.git","svn_url":"https://github.com/tapio/live-server","homepage":null,"size":509,"stargazers_count":398,"watchers_count":398,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":73,"mirror_url":null,"open_issues_count":10,"forks":73,"open_issues":10,"watchers":398,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tapio/live-server/pulls/65"},"html":{"href":"https://github.com/tapio/live-server/pull/65"},"issue":{"href":"https://api.github.com/repos/tapio/live-server/issues/65"},"comments":{"href":"https://api.github.com/repos/tapio/live-server/issues/65/comments"},"review_comments":{"href":"https://api.github.com/repos/tapio/live-server/pulls/65/comments"},"review_comment":{"href":"https://api.github.com/repos/tapio/live-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tapio/live-server/pulls/65/commits"},"statuses":{"href":"https://api.github.com/repos/tapio/live-server/statuses/072c6b87a540ebabbc5734c7c1c1ad40524db215"}}}}