Skip to content

Commit

Permalink
chore: fix windows (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladfrangu authored Apr 28, 2024
1 parent d69b059 commit 3abbeeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lint_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [ 16, 18, 20 ]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
Expand Down
12 changes: 10 additions & 2 deletions test/templates.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { spawnSync } = require('child_process');
const { spawnSync: _spawnSync } = require('child_process');
const fs = require('fs');
const os = require('os');
const path = require('path');
Expand All @@ -15,6 +15,12 @@ const PYTHON_COMMAND = /^win/.test(process.platform) ? 'python' : 'python3';
const PYTHON_VENV_COMMAND = /^win/.test(process.platform) ? '.venv\\Scripts\\python.exe' : '.venv/bin/python3';
const APIFY_COMMAND = /^win/.test(process.platform) ? 'apify.cmd' : 'apify';

const windowsOptions = /^win/.test(process.platform) ? { shell: true, windowsHide: true } : {};

function spawnSync(command, args, options = {}) {
return _spawnSync(command, args, { ...options, ...windowsOptions });
}

const APIFY_SDK_JS_LATEST_VERSION = spawnSync(NPM_COMMAND, ['view', 'apify', 'version']).stdout.toString().trim();

const APIFY_SDK_PYTHON_LATEST_VERSION = spawnSync(PYTHON_COMMAND, ['-m', 'pip', 'index', 'versions', 'apify']).stdout.toString().match(/\((.*)\)/)[1];
Expand Down Expand Up @@ -106,7 +112,9 @@ const checkPythonTemplate = () => {
};

const checkTemplateRun = () => {
const apifyRunSpawnResult = spawnSync(APIFY_COMMAND, ['run'], { options: { env: { ...process.env, APIFY_HEADLESS: '1' } } });
const apifyRunSpawnResult = spawnSync(APIFY_COMMAND, ['run'], {
env: { ...process.env, APIFY_HEADLESS: '1' },
});
checkSpawnResult(apifyRunSpawnResult);
};

Expand Down

0 comments on commit 3abbeeb

Please sign in to comment.