deployer/contrib/npm.php

38 lines
759 B
PHP
Raw Normal View History

2020-04-25 23:00:08 +03:00
<?php
2020-10-02 00:11:13 +02:00
/*
## Installing
Add to your _deploy.php_
~~~php
require 'contrib/npm.php';
~~~
## Configuration
- `bin/npm` *(optional)*: set npm binary, automatically detected otherwise.
2020-04-25 23:00:08 +03:00
2020-10-02 00:11:13 +02:00
## Usage
~~~php
after('deploy:update_code', 'npm:install');
~~~
*/
2020-04-25 23:00:08 +03:00
namespace Deployer;
set('bin/npm', function () {
return locateBinaryPath('npm');
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.
2020-04-25 23:00:08 +03:00
desc('Install npm packages');
task('npm: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/npm}} install");
});