Composer仍然包含.git目录和--prefer-dist

时间:2017-04-21 22:32:58

标签: composer-php

我将mypackage添加到composer.json中的存储库键:

"repositories": {
    "packagist": {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    "mypackage": {
        "type": "package",
        "package": {
            "name": "company_name/mypackage",
            "type": "drupal-module",
            "version": "dev-master",
            "source": {
                "type": "git",
                "url": "https://github.com/company_name/mypackage",
                "reference": "master"
            }
        }
    }
},

我运行composer require company_name/mypackage-master --prefer-dist

软件包确实已下载,但仍会添加.git目录。我想在没有.git目录的情况下下载包。我怎么做到这一点?我只有一个主分支,在github中没有发布。

1 个答案:

答案 0 :(得分:0)

在作曲家问题here中发布了问题。为了解决这个问题,我做了以下几点:

  1. composer.json文件添加到我的包中:

    {"name": "company_name/mymodule",
    "type": "drupal-custom-module",
    "description": "My description",
    "keywords": ["Drupal"],
    "license": "GPL-2.0+",
    "homepage": "https://github.com/company_name/mymodule",
    "support": {
      "issues": "https://github.com/company_name/mymodule/issues",
      "source": "https://github.com/company_name/mymodule"
    },
    "require": { }}
    
  2. 将存储库更新到composer.json文件(不是模块composer.json文件)

      "repositories": {
      "drupal-packagist": {
          "type": "composer",
          "url": "https://packages.drupal.org/8"
      },
      "my-package": {
          "type": "vcs",
          "url": "https://github.com/company_name/mypackage"
      }},
    
  3. 运行composer require company_name/mymodule --prefer-dist