Skip to content

Commit e9f2fe3

Browse files
committed
test
1 parent fdb7fb8 commit e9f2fe3

File tree

5 files changed

+4
-81
lines changed

5 files changed

+4
-81
lines changed

dist/index.cjs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ class Explain extends JsdocCommand {
143143
});
144144
handle.on('error', reject);
145145
});
146-
// console.log(handle.stdout.closed, handle.stdout.isPaused(), handle.stdout.readable, handle.stdout.destroyed, handle.stdout.errorer, handle.stdout.readableEnded)
147-
// jsdocOutput.stdout = await streamReadText(handle.stdout)
148-
// jsdocOutput.stderr = await streamReadText(handle.stderr)
149-
// console.log(jsdocOutput)
150146
try {
151147
if (code > 0) {
152148
throw new Error('jsdoc exited with non-zero code: ' + code)
@@ -166,41 +162,6 @@ class Explain extends JsdocCommand {
166162
}
167163
}
168164

169-
async _runJsdoc1 () {
170-
return new Promise((resolve, reject) => {
171-
const jsdocArgs = [
172-
this.jsdocPath,
173-
...toSpawnArgs(this.jsdocOptions),
174-
'-X',
175-
...(this.options.source.length ? this.tempFileSet.files : this.inputFileSet.files)
176-
];
177-
let jsdocOutput = { stdout: '', stderr: '' };
178-
const handle = cp.spawn('node', jsdocArgs);
179-
streamReadText(handle.stdout).then(stdout => jsdocOutput.stdout = stdout);
180-
streamReadText(handle.stderr).then(stderr => jsdocOutput.stderr = stderr);
181-
handle.on('close', (code) => {
182-
try {
183-
if (code > 0) {
184-
throw new Error('jsdoc exited with non-zero code: ' + code)
185-
} else {
186-
const explainOutput = JSON.parse(jsdocOutput.stdout);
187-
if (this.options.cache) {
188-
this.cache.write(this.cacheKey, explainOutput).then(() => resolve(explainOutput));
189-
} else {
190-
resolve(explainOutput);
191-
}
192-
}
193-
} catch (err) {
194-
const firstLineOfStdout = jsdocOutput.stdout.split(/\r?\n/)[0];
195-
const jsdocErr = new Error(jsdocOutput.stderr.trim() || firstLineOfStdout || 'Jsdoc failed.');
196-
jsdocErr.name = 'JSDOC_ERROR';
197-
jsdocErr.cause = err;
198-
reject(jsdocErr);
199-
}
200-
});
201-
})
202-
}
203-
204165
async readCache () {
205166
if (this.cache) {
206167
/* Create the cache key then check the cache for a match, returning pre-generated output if so.

lib/explain.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class Explain extends JsdocCommand {
4646
})
4747
handle.on('error', reject)
4848
})
49-
// console.log(handle.stdout.closed, handle.stdout.isPaused(), handle.stdout.readable, handle.stdout.destroyed, handle.stdout.errorer, handle.stdout.readableEnded)
50-
// jsdocOutput.stdout = await streamReadText(handle.stdout)
51-
// jsdocOutput.stderr = await streamReadText(handle.stderr)
52-
// console.log(jsdocOutput)
5349
try {
5450
if (code > 0) {
5551
throw new Error('jsdoc exited with non-zero code: ' + code)
@@ -69,41 +65,6 @@ class Explain extends JsdocCommand {
6965
}
7066
}
7167

72-
async _runJsdoc1 () {
73-
return new Promise((resolve, reject) => {
74-
const jsdocArgs = [
75-
this.jsdocPath,
76-
...toSpawnArgs(this.jsdocOptions),
77-
'-X',
78-
...(this.options.source.length ? this.tempFileSet.files : this.inputFileSet.files)
79-
]
80-
let jsdocOutput = { stdout: '', stderr: '' }
81-
const handle = cp.spawn('node', jsdocArgs)
82-
streamReadText(handle.stdout).then(stdout => jsdocOutput.stdout = stdout)
83-
streamReadText(handle.stderr).then(stderr => jsdocOutput.stderr = stderr)
84-
handle.on('close', (code) => {
85-
try {
86-
if (code > 0) {
87-
throw new Error('jsdoc exited with non-zero code: ' + code)
88-
} else {
89-
const explainOutput = JSON.parse(jsdocOutput.stdout)
90-
if (this.options.cache) {
91-
this.cache.write(this.cacheKey, explainOutput).then(() => resolve(explainOutput))
92-
} else {
93-
resolve(explainOutput)
94-
}
95-
}
96-
} catch (err) {
97-
const firstLineOfStdout = jsdocOutput.stdout.split(/\r?\n/)[0]
98-
const jsdocErr = new Error(jsdocOutput.stderr.trim() || firstLineOfStdout || 'Jsdoc failed.')
99-
jsdocErr.name = 'JSDOC_ERROR'
100-
jsdocErr.cause = err
101-
reject(jsdocErr)
102-
}
103-
})
104-
})
105-
}
106-
10768
async readCache () {
10869
if (this.cache) {
10970
/* Create the cache key then check the cache for a match, returning pre-generated output if so.

test/explain.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ test.set('.explain({ files }): files is empty', async function () {
5050
})
5151

5252
test.set('Spaces in jsdoc command path', async function () {
53-
process.env.JSDOC_PATH = 'test/fixture/folder with spaces/jsdoc'
53+
process.env.JSDOC_PATH = 'test/fixture/folder with spaces/fake-jsdoc.js'
5454
const f = new Fixture('class-all')
5555
let output = await jsdoc.explain({ files: f.sourcePath })
56-
a.ok(/a class with all of the things/.test(JSON.stringify(output)))
56+
a.equal(output.length, 4)
57+
process.env.JSDOC_PATH = ''
5758
})
5859

5960
export { test, only, skip }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log(JSON.stringify(process.argv))

test/fixture/folder with spaces/jsdoc

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)