Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions firebase-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.0.25 (unreleased)

- Replace predeploy hack with something more robust.

## 0.0.24

- Remove proxy-agent stub #6172
Expand Down
20 changes: 7 additions & 13 deletions firebase-vscode/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ const extensionConfig = {
search: /Configstore\(pkg\.name\)/g,
replace: "Configstore('firebase-tools')",
},
// TODO(hsubox76): replace with something more robust
// This is an issue with a local call to cross-env-shell.js
// and a dependency on calling the Node executable using an env
// variable which returns a string with a lot of unusual characters
// if called inside VSCode.
// We may be able to copy cross-env-shell.js into dist?
// For the node executable we can probably just call Node, still
// need to search/replace though
{
search: "childProcess.spawn(translatedCommand",
replace: "childProcess.spawn(escapedCommand"
},
// Some CLI code uses module.exports for test stubbing.
// We are using ES2020 and it doesn't recognize functions called
// as exports.functionName() or module.exports.functionName().
Expand Down Expand Up @@ -142,7 +130,13 @@ const extensionConfig = {
from: "*.js",
to: './',
context: "../src/deploy/functions/runtimes/node",
}
},
// Copy cross-env-shell.js used to run predeploy scripts
// to ensure they work in Windows
{
from: "../node_modules/cross-env/dist",
to: './cross-env/dist',
},
],
})
],
Expand Down
13 changes: 6 additions & 7 deletions src/deploy/lifecycleHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import { Options } from "../options";

function runCommand(command: string, childOptions: childProcess.SpawnOptions) {
const escapedCommand = command.replace(/\"/g, '\\"');
const isVSCode = utils.isVSCodeExtension();
const nodeExecutable = isVSCode ? "node" : process.execPath;
const crossEnvShellPath = isVSCode
? path.resolve(__dirname, "./cross-env/dist/bin/cross-env-shell.js")
: path.resolve(require.resolve("cross-env"), "..", "bin", "cross-env-shell.js");
const translatedCommand =
'"' +
process.execPath +
'" "' +
path.resolve(require.resolve("cross-env"), "..", "bin", "cross-env-shell.js") +
'" "' +
escapedCommand +
'"';
'"' + nodeExecutable + '" "' + crossEnvShellPath + '" "' + escapedCommand + '"';

return new Promise<void>((resolve, reject) => {
logger.info("Running command: " + command);
Expand Down
7 changes: 7 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,13 @@ export function isCloudEnvironment() {
return !!process.env.CODESPACES || !!process.env.GOOGLE_CLOUD_WORKSTATIONS;
}

/**
* Detect if code is running in a VSCode Extension
*/
export function isVSCodeExtension(): boolean {
return !!process.env.VSCODE_CWD;
}

/**
* Indicates whether or not this process is likely to be running in WSL.
* @return true if we're likely in WSL, false otherwise
Expand Down