Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/cli/src/util/is_integrated.rs
3314 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
use std::{env, io};
7
8
/// Gets whether the current CLI seems like it's running in integrated mode,
9
/// by looking at the location of the exe and known VS Code files.
10
pub fn is_integrated_cli() -> io::Result<bool> {
11
let exe = env::current_exe()?;
12
13
let parent = match exe.parent() {
14
Some(parent) if parent.file_name().and_then(|n| n.to_str()) == Some("bin") => parent,
15
_ => return Ok(false),
16
};
17
18
let parent = match parent.parent() {
19
Some(p) => p,
20
None => return Ok(false),
21
};
22
23
let expected_file = if cfg!(target_os = "macos") {
24
"node_modules.asar"
25
} else {
26
"resources.pak"
27
};
28
29
Ok(parent.join(expected_file).exists())
30
}
31
32