Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 15a3ec9

Browse files
committed
Add bundled flow
This is used as a third option for users that do not flow installed globally or locally
1 parent 12c900e commit 15a3ec9

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
### Master
22

3+
### 0.7.0
4+
5+
* Bundles `flow-bin` with the plugin to use in cases where it has not been
6+
installed globally or locally. - [@BrainMaestro]() [#118](https://github.com/flowtype/flow-for-vscode/pull/118)
7+
38
### 0.6.0
49

510
* Adds the status indicator (spinner) to the statusbar which appears when flow is

lib/pkg/flow-base/lib/FlowHelpers.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {checkOutput} from '../../commons-node/process';
1818
import fsPromise from '../../commons-node/fsPromise';
1919
import LRU from 'lru-cache';
2020
import invariant from 'assert';
21+
import path from 'path';
2122

2223
import {getLogger} from '../../nuclide-logging/lib/main';
2324
const logger = getLogger();
@@ -166,13 +167,17 @@ async function getPathToFlow(): Promise<string> {
166167
const config = global.vscode.workspace.getConfiguration('flow');
167168
const shouldUseNodeModule = config.get('useNPMPackagedFlow');
168169
const userPath = config.get('pathToFlow');
170+
const nodeModuleFlowPath = nodeModuleFlowLocation(global.vscode.workspace.rootPath)
169171

170-
if (shouldUseNodeModule && await canFindFlow(nodeModuleFlowLocation())){
171-
global.cachedPathToFlowBin = nodeModuleFlowLocation();
172+
if (shouldUseNodeModule && await canFindFlow(nodeModuleFlowPath)){
173+
global.cachedPathToFlowBin = nodeModuleFlowPath;
172174
} else if (await canFindFlow(userPath)) {
173175
global.cachedPathToFlowBin = userPath;
176+
} else if (await canFindFlow('flow')) {
177+
global.cachedPathToFlowBin = 'flow';
174178
} else {
175-
global.cachedPathToFlowBin = "flow";
179+
const extensionRoot = path.resolve(__dirname, '../../../../');
180+
global.cachedPathToFlowBin = nodeModuleFlowLocation(extensionRoot)
176181
}
177182

178183
logger.info("Path to Flow: " + global.cachedPathToFlowBin);
@@ -185,11 +190,11 @@ async function getPathToFlow(): Promise<string> {
185190
* @return The potential path to Flow on the user's machine if they are using NPM/Yarn to manage
186191
* their installs of flow.
187192
*/
188-
function nodeModuleFlowLocation(): string {
193+
function nodeModuleFlowLocation(rootPath: string): string {
189194
if (process.platform === 'win32') {
190-
return `${global.vscode.workspace.rootPath}\\node_modules\\.bin\\flow.cmd`
195+
return `${rootPath}\\node_modules\\.bin\\flow.cmd`
191196
} else {
192-
return `${global.vscode.workspace.rootPath}/node_modules/.bin/flow`
197+
return `${rootPath}/node_modules/.bin/flow`
193198
}
194199
}
195200

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"cross-spawn": "^4.0.0",
7373
"dequeue": "^1.0.5",
7474
"event-kit": "^2.0.0",
75+
"flow-bin": "^0.43.0",
7576
"fs-plus": "^2.8.2",
7677
"fuzzaldrin": "^2.1.0",
7778
"js-beautify": "^1.6.12",
@@ -91,7 +92,6 @@
9192
"babel-plugin-transform-flow-strip-types": "^6.0.14",
9293
"babel-preset-es2015": "^6.1.4",
9394
"babel-preset-stage-1": "^6.1.2",
94-
"flow-bin": "^0.43.0",
9595
"vscode": "0.11.x"
9696
},
9797
"icon": "flow-logo.png",

0 commit comments

Comments
 (0)