Trying to install node.js via composer (for automation).
"repositories": [
"type": "package",
"package": {
"name": "nodejs/nodejs",
"version": "0.12.6",
"dist": {
"type": "gzip",
"url": "https://nodejs.org/dist/v0.12.6/node-v0.12.6-linux-x64.tar.gz"
}
}
}
],
"require": {
"nodejs/nodejs": "0.12.*"
}
Problem is, I can either use tar
or gzip
to unpack the archieve.
Available types: git, svn, hg, perforce, zip, rar, tar, gzip, phar, file.
The nodejs package obviously uses both.
How can I unpack .tar.gz
packed files using composer?
I know I could use post-update-cmd
and post-install-cmd
commands and manually execute untar/gunzip, but that's not the way composer is ment to be.
Best Answer
The "tar" option understands both bare
.tar
,.tar.gz
, and even.tar.bz2
so just specify"type": "tar"
and there is no need to specify the"gz"
. It figures out the decompression on it's own.I ran into this issue, and was also initially confused, trying to auto-deploy a php app that used a proprietary library. However I tried just "tar", it worked! My
repositories
JSON part looks a little goofy because of the unusual structure of the tar archive, but it does work. It looked something like this:You can find, somewhat obscurely in the Composer API documentation (not the end-user manual) that the
.tar
,.tar.gz
and.tar.bz2
are all three officially supported by"type": "tar"
. Apparently, it is handled internally by composer by theComposer\Downloader\TarDownloader
class.