This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 683
/
main.js
176 lines (166 loc) · 4.28 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
import type {
AutoGenConfig,
NuclideDebuggerProvider,
} from 'nuclide-debugger-common/types';
import * as React from 'react';
import createPackage from 'nuclide-commons-atom/createPackage';
import {AutoGenLaunchAttachProvider} from 'nuclide-debugger-common/AutoGenLaunchAttachProvider';
import {VsAdapterTypes, VsAdapterNames} from 'nuclide-debugger-common';
class Activation {
constructor() {}
dispose() {}
createDebuggerProvider(): NuclideDebuggerProvider {
return {
type: VsAdapterTypes.NODE,
getLaunchAttachProvider: connection => {
return new AutoGenLaunchAttachProvider(
VsAdapterNames.NODE,
connection,
getNodeConfig(),
);
},
};
}
}
function getNodeConfig(): AutoGenConfig {
const program = {
name: 'program',
type: 'string',
description: 'Absolute path to the program.',
required: true,
visible: true,
};
const cwd = {
name: 'cwd',
type: 'string',
description:
'Absolute path to the working directory of the program being debugged.',
required: true,
visible: true,
};
const stopOnEntry = {
name: 'stopOnEntry',
type: 'boolean',
description: 'Automatically stop program after launch.',
defaultValue: false,
required: false,
visible: true,
};
const args = {
name: 'args',
type: 'array',
itemType: 'string',
description: 'Command line arguments passed to the program.',
defaultValue: [],
required: false,
visible: true,
};
const runtimeExecutable = {
name: 'runtimeExecutable',
type: 'string',
description:
'(Optional) Runtime to use, an absolute path or the name of a runtime available on PATH',
required: false,
visible: true,
};
const env = {
name: 'env',
type: 'object',
description:
'(Optional) Environment variables (e.g. SHELL=/bin/bash PATH=/bin)',
defaultValue: {},
required: false,
visible: true,
};
const outFiles = {
name: 'outFiles',
type: 'array',
itemType: 'string',
description:
'(Optional) When source maps are enabled, these glob patterns specify the generated JavaScript files',
defaultValue: [],
required: false,
visible: true,
};
const protocol = {
name: 'protocol',
type: 'string',
description: '',
defaultValue: 'inspector',
required: false,
visible: false,
};
const consoleEnum = {
name: 'console',
type: 'enum',
enums: ['internalConsole', 'integratedTerminal'],
description:
'Integrated Terminal means that it will run in a terminal that can interact with standard input and output.',
defaultValue: 'internalConsole',
required: true,
visible: true,
};
const port = {
name: 'port',
type: 'number',
description: 'Port',
required: true,
visible: true,
};
return {
launch: {
launch: true,
vsAdapterType: VsAdapterTypes.NODE,
properties: [
program,
cwd,
stopOnEntry,
args,
runtimeExecutable,
env,
outFiles,
protocol,
consoleEnum,
],
scriptPropertyName: 'program',
cwdPropertyName: 'cwd',
scriptExtension: '.js',
header: (
<p>This is intended to debug node.js files (for node version 6.3+).</p>
),
getProcessName(values) {
let processName = values.program;
const lastSlash = processName.lastIndexOf('/');
if (lastSlash >= 0) {
processName = processName.substring(
lastSlash + 1,
processName.length,
);
}
return processName + ' (Node)';
},
},
attach: {
launch: false,
vsAdapterType: VsAdapterTypes.NODE,
properties: [port],
scriptExtension: '.js',
header: <p>Attach to a running node.js process</p>,
getProcessName(values) {
return 'Port: ' + values.port + ' (Node attach)';
},
},
};
}
createPackage(module.exports, Activation);