deployer/contrib/npm.php
Anton Medvedev 29a643b623 v7
2020-05-16 18:02:17 +03:00

34 lines
937 B
PHP

<?php
/* (c) Anton Medvedev <anton@medv.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
set('bin/npm', function () {
return run('which npm');
});
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}}');
// If package.json is unmodified, then skip running `npm install`
if (!run('diff {{previous_release}}/package.json {{release_path}}/package.json')) {
return;
}
}
}
run("cd {{release_path}} && {{bin/npm}} install");
});
desc('Install npm packages with a clean slate');
task('npm:ci', function () {
run("cd {{release_path}} && {{bin/npm}} ci");
});