{"action":"created","comment":{"url":"https://api.github.com/repos/strongloop/strong-pack/pulls/comments/45889909","id":45889909,"diff_hunk":"@@ -18,27 +18,35 @@ var FILTER = filterize([\n   /^\\._/,\n ]);\n \n-function pack(folder) {\n-  var tarPack = tar.Pack({ noProprietary: true });\n-  var contents = fstream.Reader({\n-    path: folder,\n-    type: 'Directory',\n-    isDirectory: true,\n-    filter: FILTER,\n+function pack(folder, opts) {\n+  opts = opts || {};\n+  opts.injections = opts.injections || [];\n+  var tarPack = tar.pack(folder, {\n+    ignore: FILTER,\n+    map: function(header) {\n+      if (header.name === '.') {\n+        header.name = 'package';\n+      } else {\n+        header.name = 'package/' + header.name;\n+      }\n+      return header;\n+    },\n   });\n   if (debug.enabled) {\n-    contents.on('error', debug.bind(null, 'err reading folder'));\n     tarPack.on('error', debug.bind(null, 'tar creation error'));\n   }\n-  return contents.pipe(tarPack);\n+  opts.injections.forEach(function(i) {\n+    tarPack.entry({name: i.path}, i.body);","path":"index.js","position":42,"original_position":42,"commit_id":"97c418a11eba683da8d2bfda0e741d6fff63de40","original_commit_id":"97c418a11eba683da8d2bfda0e741d6fff63de40","user":{"login":"rmg","id":17978,"avatar_url":"https://avatars.githubusercontent.com/u/17978?v=3","gravatar_id":"","url":"https://api.github.com/users/rmg","html_url":"https://github.com/rmg","followers_url":"https://api.github.com/users/rmg/followers","following_url":"https://api.github.com/users/rmg/following{/other_user}","gists_url":"https://api.github.com/users/rmg/gists{/gist_id}","starred_url":"https://api.github.com/users/rmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmg/subscriptions","organizations_url":"https://api.github.com/users/rmg/orgs","repos_url":"https://api.github.com/users/rmg/repos","events_url":"https://api.github.com/users/rmg/events{/privacy}","received_events_url":"https://api.github.com/users/rmg/received_events","type":"User","site_admin":false},"body":"Pretty much.\r\n\r\nBasically the `tar-fs` module is awesome and provides the APIs I keep wrapping around the `tar` module.","created_at":"2015-11-25T16:46:21Z","updated_at":"2015-11-25T16:46:21Z","html_url":"https://github.com/strongloop/strong-pack/pull/2#discussion_r45889909","pull_request_url":"https://api.github.com/repos/strongloop/strong-pack/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/strongloop/strong-pack/pulls/comments/45889909"},"html":{"href":"https://github.com/strongloop/strong-pack/pull/2#discussion_r45889909"},"pull_request":{"href":"https://api.github.com/repos/strongloop/strong-pack/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/strongloop/strong-pack/pulls/2","id":51763165,"html_url":"https://github.com/strongloop/strong-pack/pull/2","diff_url":"https://github.com/strongloop/strong-pack/pull/2.diff","patch_url":"https://github.com/strongloop/strong-pack/pull/2.patch","issue_url":"https://api.github.com/repos/strongloop/strong-pack/issues/2","number":2,"state":"open","locked":false,"title":"Injection support","user":{"login":"rmg","id":17978,"avatar_url":"https://avatars.githubusercontent.com/u/17978?v=3","gravatar_id":"","url":"https://api.github.com/users/rmg","html_url":"https://github.com/rmg","followers_url":"https://api.github.com/users/rmg/followers","following_url":"https://api.github.com/users/rmg/following{/other_user}","gists_url":"https://api.github.com/users/rmg/gists{/gist_id}","starred_url":"https://api.github.com/users/rmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmg/subscriptions","organizations_url":"https://api.github.com/users/rmg/orgs","repos_url":"https://api.github.com/users/rmg/repos","events_url":"https://api.github.com/users/rmg/events{/privacy}","received_events_url":"https://api.github.com/users/rmg/received_events","type":"User","site_admin":false},"body":"@sam-github @pthieu I ended up having to switch to a different tar implementation to get this working.\r\n\r\nNow that it is working, though, I'm not entirely happy with the API:\r\n\r\n```js\r\nvar pack = require('strong-pack');\r\nvar appTar = pack('path/to/app', {\r\n  injections: [\r\n    {path: '.injected.json', body: JSON.stringify('some json')},\r\n  ]\r\n});\r\nappTar.pipe(gz).pipe(tgz);\r\n```\r\n\r\nBecause of the change to the underlying tar implementation, there's actually an API already provided that might be just as convenient - or even more convenient:\r\n```js\r\nvar pack = require('strong-pack');\r\nvar appTar = pack('path/to/app');\r\nappTar.entry({name: 'package/.injected.json'}, JSON.stringify('some json'));\r\nappTar.pipe(gz).pipe(tgz);\r\n```","created_at":"2015-11-25T08:10:29Z","updated_at":"2015-11-25T16:46:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d5b11301ba08cbea6fac2b9b8d89cf4824cde4e","assignee":{"login":"pthieu","id":2908721,"avatar_url":"https://avatars.githubusercontent.com/u/2908721?v=3","gravatar_id":"","url":"https://api.github.com/users/pthieu","html_url":"https://github.com/pthieu","followers_url":"https://api.github.com/users/pthieu/followers","following_url":"https://api.github.com/users/pthieu/following{/other_user}","gists_url":"https://api.github.com/users/pthieu/gists{/gist_id}","starred_url":"https://api.github.com/users/pthieu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pthieu/subscriptions","organizations_url":"https://api.github.com/users/pthieu/orgs","repos_url":"https://api.github.com/users/pthieu/repos","events_url":"https://api.github.com/users/pthieu/events{/privacy}","received_events_url":"https://api.github.com/users/pthieu/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/strongloop/strong-pack/pulls/2/commits","review_comments_url":"https://api.github.com/repos/strongloop/strong-pack/pulls/2/comments","review_comment_url":"https://api.github.com/repos/strongloop/strong-pack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/strongloop/strong-pack/issues/2/comments","statuses_url":"https://api.github.com/repos/strongloop/strong-pack/statuses/97c418a11eba683da8d2bfda0e741d6fff63de40","head":{"label":"strongloop:injection-support","ref":"injection-support","sha":"97c418a11eba683da8d2bfda0e741d6fff63de40","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":46528447,"name":"strong-pack","full_name":"strongloop/strong-pack","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/strong-pack","description":"Like npm pack but more inclusive","fork":false,"url":"https://api.github.com/repos/strongloop/strong-pack","forks_url":"https://api.github.com/repos/strongloop/strong-pack/forks","keys_url":"https://api.github.com/repos/strongloop/strong-pack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/strong-pack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/strong-pack/teams","hooks_url":"https://api.github.com/repos/strongloop/strong-pack/hooks","issue_events_url":"https://api.github.com/repos/strongloop/strong-pack/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/strong-pack/events","assignees_url":"https://api.github.com/repos/strongloop/strong-pack/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/strong-pack/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/strong-pack/tags","blobs_url":"https://api.github.com/repos/strongloop/strong-pack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/strong-pack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/strong-pack/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/strong-pack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/strong-pack/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/strong-pack/languages","stargazers_url":"https://api.github.com/repos/strongloop/strong-pack/stargazers","contributors_url":"https://api.github.com/repos/strongloop/strong-pack/contributors","subscribers_url":"https://api.github.com/repos/strongloop/strong-pack/subscribers","subscription_url":"https://api.github.com/repos/strongloop/strong-pack/subscription","commits_url":"https://api.github.com/repos/strongloop/strong-pack/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/strong-pack/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/strong-pack/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/strong-pack/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/strong-pack/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/strong-pack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/strong-pack/merges","archive_url":"https://api.github.com/repos/strongloop/strong-pack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/strong-pack/downloads","issues_url":"https://api.github.com/repos/strongloop/strong-pack/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/strong-pack/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/strong-pack/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/strong-pack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/strong-pack/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/strong-pack/releases{/id}","created_at":"2015-11-20T00:18:04Z","updated_at":"2015-11-24T23:04:50Z","pushed_at":"2015-11-25T08:18:56Z","git_url":"git://github.com/strongloop/strong-pack.git","ssh_url":"git@github.com:strongloop/strong-pack.git","clone_url":"https://github.com/strongloop/strong-pack.git","svn_url":"https://github.com/strongloop/strong-pack","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"strongloop:master","ref":"master","sha":"727b23625b7969ffbe8d201e0cb910d71b7685a5","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":46528447,"name":"strong-pack","full_name":"strongloop/strong-pack","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/strong-pack","description":"Like npm pack but more inclusive","fork":false,"url":"https://api.github.com/repos/strongloop/strong-pack","forks_url":"https://api.github.com/repos/strongloop/strong-pack/forks","keys_url":"https://api.github.com/repos/strongloop/strong-pack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/strong-pack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/strong-pack/teams","hooks_url":"https://api.github.com/repos/strongloop/strong-pack/hooks","issue_events_url":"https://api.github.com/repos/strongloop/strong-pack/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/strong-pack/events","assignees_url":"https://api.github.com/repos/strongloop/strong-pack/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/strong-pack/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/strong-pack/tags","blobs_url":"https://api.github.com/repos/strongloop/strong-pack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/strong-pack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/strong-pack/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/strong-pack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/strong-pack/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/strong-pack/languages","stargazers_url":"https://api.github.com/repos/strongloop/strong-pack/stargazers","contributors_url":"https://api.github.com/repos/strongloop/strong-pack/contributors","subscribers_url":"https://api.github.com/repos/strongloop/strong-pack/subscribers","subscription_url":"https://api.github.com/repos/strongloop/strong-pack/subscription","commits_url":"https://api.github.com/repos/strongloop/strong-pack/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/strong-pack/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/strong-pack/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/strong-pack/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/strong-pack/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/strong-pack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/strong-pack/merges","archive_url":"https://api.github.com/repos/strongloop/strong-pack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/strong-pack/downloads","issues_url":"https://api.github.com/repos/strongloop/strong-pack/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/strong-pack/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/strong-pack/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/strong-pack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/strong-pack/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/strong-pack/releases{/id}","created_at":"2015-11-20T00:18:04Z","updated_at":"2015-11-24T23:04:50Z","pushed_at":"2015-11-25T08:18:56Z","git_url":"git://github.com/strongloop/strong-pack.git","ssh_url":"git@github.com:strongloop/strong-pack.git","clone_url":"https://github.com/strongloop/strong-pack.git","svn_url":"https://github.com/strongloop/strong-pack","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/strongloop/strong-pack/pulls/2"},"html":{"href":"https://github.com/strongloop/strong-pack/pull/2"},"issue":{"href":"https://api.github.com/repos/strongloop/strong-pack/issues/2"},"comments":{"href":"https://api.github.com/repos/strongloop/strong-pack/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/strongloop/strong-pack/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/strongloop/strong-pack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/strongloop/strong-pack/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/strongloop/strong-pack/statuses/97c418a11eba683da8d2bfda0e741d6fff63de40"}}}}