deployer/contrib/yarn.php

29 lines
680 B
PHP
Raw Normal View History

2020-04-25 23:00:08 +03:00
<?php
2020-10-02 00:11:13 +02:00
/*
## Configuration
2020-04-25 23:00:08 +03:00
2020-10-02 00:11:13 +02:00
- **bin/yarn** *(optional)*: set Yarn binary, automatically detected otherwise.
## Usage
```php
after('deploy:update_code', 'yarn:install');
```
*/
2020-04-25 23:00:08 +03:00
namespace Deployer;
set('bin/yarn', function () {
2021-11-05 15:23:34 +01:00
return which('yarn');
2020-04-25 23:00:08 +03:00
});
2020-10-02 00:11:13 +02:00
// In there is a {{previous_release}}, node_modules will be copied from it before installing deps with yarn.
2021-11-08 22:59:39 +01:00
desc('Installs Yarn packages');
2020-04-25 23:00:08 +03:00
task('yarn:install', function () {
if (has('previous_release')) {
if (test('[ -d {{previous_release}}/node_modules ]')) {
run('cp -R {{previous_release}}/node_modules {{release_path}}');
}
}
run("cd {{release_path}} && {{bin/yarn}}");
});