Skip to content

Commit fcd8d2d

Browse files
authored
Merge pull request #95 from ngdenterprise/neoxp-update
Update `neoxp` to fix relative path support in invoke files
2 parents 0282477 + 3305cb6 commit fcd8d2d

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
},
322322
"scripts": {
323323
"bundle-nxp": "npm run bundle-nxp-download && npm run bundle-nxp-extract",
324-
"bundle-nxp-download": "shx rm -rf deps/nxp && shx mkdir -p deps/nxp && nwget \"https://github.com/neo-project/neo-express/releases/download/2.0.35-preview/Neo.Express.2.0.35-preview.nupkg\" -O deps/nxp/nxp.nupkg",
324+
"bundle-nxp-download": "shx rm -rf deps/nxp && shx mkdir -p deps/nxp && nwget \"https://github.com/neo-project/neo-express/releases/download/2.0.37-preview/Neo.Express.2.0.37-preview.nupkg\" -O deps/nxp/nxp.nupkg",
325325
"bundle-nxp-extract": "cd deps/nxp && extract-zip nxp.nupkg",
326326
"compile": "npm run compile-ext && npm run compile-panel",
327327
"compile-ext": "webpack --config src/extension/webpack.config.js --mode development",

src/extension/commands/neoExpressCommands.ts

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export default class NeoExpressCommands {
176176
return;
177177
}
178178
const output = await neoExpress.runUnsafe(
179+
undefined,
179180
command,
180181
"-i",
181182
identifier.configPath

src/extension/neoExpress/neoExpress.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,25 @@ export default class NeoExpress {
5959
}
6060
});
6161
});
62-
62+
6363
terminal.show();
64-
64+
6565
// Give the terminal a chance to get a lock on the blockchain before
6666
// starting to do any offline commands.
6767
await hasStarted;
68-
68+
6969
return terminal;
7070
}
7171

72-
async run(
72+
run(
73+
command: Command,
74+
...options: string[]
75+
): Promise<{ message: string; isError?: boolean }> {
76+
return this.runInDirectory(undefined, command, ...options);
77+
}
78+
79+
async runInDirectory(
80+
cwd: string | undefined,
7381
command: Command,
7482
...options: string[]
7583
): Promise<{ message: string; isError?: boolean }> {
@@ -78,7 +86,7 @@ export default class NeoExpress {
7886
const releaseLock = await this.getRunLock();
7987
try {
8088
const startedAtInternal = new Date().getTime();
81-
const result = await this.runUnsafe(command, ...options);
89+
const result = await this.runUnsafe(cwd, command, ...options);
8290
const endedAtInternal = new Date().getTime();
8391
durationInternal = endedAtInternal - startedAtInternal;
8492
return result;
@@ -98,6 +106,7 @@ export default class NeoExpress {
98106
}
99107

100108
async runUnsafe(
109+
cwd: string | undefined,
101110
command: string,
102111
...options: string[]
103112
): Promise<{ message: string; isError?: boolean }> {
@@ -112,7 +121,9 @@ export default class NeoExpress {
112121
try {
113122
return new Promise((resolve, reject) => {
114123
const startedAt = new Date().getTime();
115-
const process = childProcess.spawn(this.dotnetPath, dotNetArguments);
124+
const process = childProcess.spawn(this.dotnetPath, dotNetArguments, {
125+
cwd,
126+
});
116127
let complete = false;
117128
const watchdog = () => {
118129
if (!complete && new Date().getTime() - startedAt > TIMEOUT_IN_MS) {

src/extension/panelControllers/invokeFilePanelController.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export default class InvokeFilePanelController extends PanelControllerBase<
293293
}
294294
}
295295

296-
private async runFile(path: string) {
296+
private async runFile(filePath: string) {
297297
let connection = this.activeConnection.connection;
298298
if (!connection) {
299299
await this.activeConnection.connect();
@@ -330,14 +330,15 @@ export default class InvokeFilePanelController extends PanelControllerBase<
330330
}
331331
await this.document.save();
332332
await this.updateViewState({ collapseTransactions: false });
333-
const result = await this.neoExpress.run(
333+
const result = await this.neoExpress.runInDirectory(
334+
path.dirname(this.document.uri.fsPath),
334335
"contract",
335336
"invoke",
336337
"-w",
337338
witnessScope,
338339
"-i",
339340
connection.blockchainIdentifier.configPath,
340-
path,
341+
filePath,
341342
account
342343
);
343344
if (result.isError) {

0 commit comments

Comments
 (0)