Skip to content

Commit

Permalink
DEBUG WIN13
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Mar 15, 2024
1 parent 6e514f0 commit 9c55633
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
5 changes: 2 additions & 3 deletions hooks/lando-setup-build-engine-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ module.exports = async (lando, options) => {
},
requiresRestart: async () => {
// if wsl is not installed then this requires a restart
const opts = {debug, ignoreReturnCode: true};
const {code, stdout} = await require('../utils/run-command')('powershell', ['-Command', 'wsl --status'], opts);
const {code, stdout} = await require('../utils/get-wsl-status')({debug});
console.log(stdout);
console.log(Buffer.from(stdout, 'utf8').toString('utf16le'));

const hasFeaturesEnabled = !stdout.includes('"Virtual Machine Platform"') && !stdout.includes('"Windows Subsystem for Linux"'); // eslint-disable-line max-len
const installed = code === 0 && hasFeaturesEnabled;
lando.log.debug('wsl installed=%o, restart %o', installed, installed ? 'not required' : 'required');
debug('wsl installed=%o, restart %o', installed, installed ? 'not required' : 'required');
return !installed;
},
task: async (ctx, task) => {
Expand Down
22 changes: 22 additions & 0 deletions utils/get-wsl-status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

// Modules
const merge = require('lodash/merge');

// get the bosmang
const defaults = {
debug: require('debug')('@lando/get-wsl-status'),
ignoreReturnCode: true,
env: {...process.env, WSL_UTF8: 1},
};

module.exports = async (options = {}) => {
const args = ['-Command', 'wsl --status'];
const opts = merge({}, defaults, options);
const {debug} = opts;
const {code, stdout} = await require('./run-command')('powershell', args, opts);
debug('wsl status', opts);

return {code, stdout};
};

6 changes: 2 additions & 4 deletions utils/run-command.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


'use strict';

// Modules
Expand All @@ -18,10 +20,6 @@ module.exports = (command, args = [], options = {}, stdout = '', stderr = '') =>
options = merge({}, defaults, options);
const debug = options.debug;

// this is a weirdly odd and specific thing we need to do
// @TODO: do we need to scope this at all or is it fine to just set regardless?
options.env.WSL_UTF8 = 1;

// birth
debug('running command %o %o', command, args);
const child = spawn(command, args, options);
Expand Down

0 comments on commit 9c55633

Please sign in to comment.