2

我有一个composer.json像这样的文件:

{
    "require": {
        "components/jquery": "*",
        "ajbdev/requirejs": "dev-master"
    }
}

但我只想得到ajbdev/requirejs/require.js文件。我怎样才能用 Composer 做到这一点?

编辑:

正如@dev-null-dweller 建议的那样,以下对我有用,但它是最好的解决方案吗?

{
    "require": {
        "components/jquery": "*"
    },
    "scripts": {
        "post-autoload-dump": "rm -rf vendor/ajbdev && mkdir vendor/ajbdev && mkdir vendor/ajbdev/requirejs && wget -q --no-check-certificate -O vendor/ajbdev/requirejs/require.js https://raw.github.com/ajbdev/requirejs/master/require.js"
    }
}
4

2 回答 2

2

You can use scripting hook and get this file by providing full URL to it, ie:

{
    "require": {
        "components/jquery": "*"
    },
    "scripts": {
        "post-autoload-dump": "wget -q -P vendor/file/output/dir/ --no-check-certificate https://raw.github.com/ajbdev/requirejs/master/require.js"
    }
}
于 2013-03-30T21:31:05.663 回答
1

编辑

  • 在 github 上 fork 包,
  • 删除除您希望在项目中包含的文件和包 composer.json 之外的所有文件。
  • 将您的 fork 添加为自定义存储库:

    {
        "repositories": [
             {
                 "type":"vcs",
                 "url":"git@github.com:Shalkydri/requirejs.git"
             }
        ],
        "require": {
             "components/jquery": "*",
             "ajbdev/requirejs": "dev-master"
        }
    } 
    

编辑

要仅获取引用的“require.js”文件,您可以在在 github上找到文件及其原始版本之前从 packagist ( https://packagist.org/packages/ajbdev/requirejs )找到相应的 github 包:

https://github.com/ajbdev/requirejs/blob/master/require.js https://raw.github.com/ajbdev/requirejs/master/require.js

Original Answer

You can execute the following command before providing any version constraint such as "dev-master"

php composer.phar require ajbdev/requirejs
于 2013-03-30T21:05:58.743 回答