Skip to content

Commit

Permalink
feat: Hides cmd on Windows #89
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Drop cross-spawn in favor of Node.js spawn
  • Loading branch information
Quentin Rossetti committed Jul 11, 2021
1 parent b7f799c commit e955111
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 66 deletions.
53 changes: 9 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"node": ">=10"
},
"dependencies": {
"cross-spawn": "^7.0.2",
"debug": "^4.3.2",
"lodash.defaultsdeep": "^4.6.1",
"lodash.defaultto": "^4.14.0",
Expand All @@ -47,7 +46,7 @@
},
"optionalDependencies": {},
"devDependencies": {
"chai": "^4.2.0",
"chai": "^4.3.4",
"esm": "^3.2.25",
"fs-readdir-recursive": "^1.1.0",
"is-child-process": "^1.0.2",
Expand Down
8 changes: 5 additions & 3 deletions src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

const debug = require('debug')('node-7z')
const spawn = require('cross-spawn')
const spawn = require('child_process').spawn
const { Readable } = require('stream')
const { STAGE_HEADERS } = require('./references')

Expand Down Expand Up @@ -42,7 +42,6 @@ const createFactory = ({
.concat(Flags.fromOptions(options))
seven._isProgressFlag = seven._args.includes('-bsp1')
seven._stage = STAGE_HEADERS
seven._spawnOptions = options.$spawnOptions
seven._matchBodyData = Parser.fetch(options._command, 'bodyData')
seven._matchEndOfHeaders = Parser.fetch(options._command, 'endOfHeaders')
seven._matchEndOfBody = Parser.fetch(options._command, 'endOfBody')
Expand All @@ -68,7 +67,10 @@ const listenFactory = ({
}

const run = stream => {
const spawnOptions = Object.assign({ detached: true }, stream._spawnOptions)
const spawnOptions = Object.assign({
detached: true,
windowsHide: true
}, stream._spawnOptions)
stream._childProcess = spawn(stream._bin, stream._args, spawnOptions)
return stream
}
Expand Down
17 changes: 0 additions & 17 deletions test/unit/lifecycle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,6 @@ describe('Unit: lifecycle.js', function () {
})
})

it('should populate child process', function () {
const sevenFake = new Readable({ read () {} })
sevenFake._bin = 'npm'
sevenFake._args = []
const r = Seven.run(sevenFake)
expect(isChildProcess(r._childProcess)).to.eql(true)
})

it('should accept child process options', function () {
const sevenFake = new Readable({ read () {} })
sevenFake._bin = 'npm'
sevenFake._args = []
sevenFake._spawnOptions = { cmd: '.' }
const r = Seven.run(sevenFake)
expect(isChildProcess(r._childProcess)).to.eql(true)
})

it('should be chainable', function () {
const sevenFake = sevenFakeFactory()
sevenFake._bin = 'not_a_program'
Expand Down

0 comments on commit e955111

Please sign in to comment.