#node.js #angular #gulp
Вопрос:
У меня есть существующий проект, и я пытаюсь внести изменения в свой VPS-сервер. Я использую ubuntu-последнюю версию runner, и мне нужно внести изменения с помощью Gulp на моем сервере через SSH. Для этого я создал следующее действие:
name: Committing to test on: push: branches: [test] jobs: deploy: runs-on: ubuntu-latest strategy: matrix: node-version: [12.14.1] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - name: Install dependencies run: npm install --save-dev gulp-ssh - run: npm run build --if-present - name: Deploy to Server uses: easingthemes/ssh-deploy@main env: SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_TEST }} ARGS: "-rltgoDzvO" SOURCE: "dist/" REMOTE_HOST: ${{ secrets.REMOTE_HOST }} REMOTE_USER: ${{ secrets.REMOTE_USER_TEST }} TARGET: ${{ secrets.REMOTE_TARGET_TEST }} EXCLUDE: "/dist/, /node_modules/" - run: gulp dist
Когда я выполняю действие, я получаю следующую ошибку:
[08:28:09] Starting 'dist'... [08:28:09] 'dist' errored after 36 ms [08:28:09] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type object at Object.openSync (fs.js:432:10) at Object.readFileSync (fs.js:342:35) at /home/runner/work/loovla/loovla/gulpfile.js:59:22 at dist (/home/runner/work/loovla/loovla/node_modules/undertaker/lib/set-task.js:13:15) at bound (domain.js:419:14) at runBound (domain.js:432:12) at asyncRunner (/home/runner/work/loovla/loovla/node_modules/async-done/index.js:55:18) at processTicksAndRejections (internal/process/task_queues.js:76:11) Error: Process completed with exit code 1.
Мой gulpfile.js выглядит так:
const gulp = require('gulp'); const HubRegistry = require('gulp-hub'); const cheerio = require('cheerio'); const rimraf = require('rimraf'); const fs = require('fs'); const hub = new HubRegistry(['tasks/*.js']); gulp.registry(hub); 'use strict' var GulpSSH = require('gulp-ssh') var config = { host: 'MYHOSTIP', port: 22, username: 'MYUSERNAME', privateKey: fs.readFileSync('/home/runner/.ssh/deploy_key') } var gulpSSH = new GulpSSH({ ignoreErrors: false, sshConfig: config }) gulp.task('dist', function(done) { //remove old dist files from laravel public folder //gulp.src('./../server/public/client', {read: false}).pipe(clean({force: true})); rimraf.sync('/public_html/public/client'); //copy dist folder into laravel public folder gulp.src(['./dist/client/browser/**/*', '!./dist/client/browser/index.html', '!./dist/client/browser/stats.json']).pipe(gulpSSH.dest('/public_html/public/client')); const $ = cheerio.load(fs.readFileSync('./dist/client/browser/index.html', 'utf8')); //get script tags that need to be injected into main laravel view const scripts = $('script').map(function(i, el) { return $('lt;divgt;').append($(el)).html(); }).toArray(); //get css tags that need to be injected into main laravel view const styles = $('link').filter(function(i, el) { return $(el).attr('href').indexOf('client/styles.') gt; -1; }).map(function(i, el) { return $('lt;divgt;').append($(el)).html(); }).toArray(); //js scripts replace regex const jsSearch = /{{--angular scripts begin--}}[sS]*{{--angular scripts end--}}/; const jsReplaceStr = '{{--angular scripts begin--}}' "ntt" scripts.join("ntt") "nt{{--angular scripts end--}}"; //css styles replace regex const cssSearch = /{{--angular styles begin--}}[sS]*{{--angular styles end--}}/; const cssReplaceStr = '{{--angular styles begin--}}' "ntt" styles.join("ntt") "nt{{--angular styles end--}}"; const laravelViewPath = (gulpSSH.dest('/public_html/resources/views/app.blade.php')); //replace app stylesheet links and js script tags with new ones let content = fs.readFileSync(laravelViewPath, 'utf8'); content = content.replace(jsSearch, jsReplaceStr).replace(cssSearch, cssReplaceStr); fs.writeFileSync(laravelViewPath, content, 'utf8'); done(); });
Что не так с путем const laravelViewPath = (gulpSSH.dest(‘/public_html/resources/views/app.blade.php’)); ?