Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build/globals.js",
"build/deno.js"
],
"limit": "849.55 kB",
"limit": "850.50 kB",
"brotli": false,
"gzip": false
},
Expand Down Expand Up @@ -66,7 +66,7 @@
"README.md",
"LICENSE"
],
"limit": "911.30 kB",
"limit": "912.20 kB",
"brotli": false,
"gzip": false
}
Expand Down
9 changes: 8 additions & 1 deletion build/core.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,14 @@ function setShell(n, ps3 = true) {
}
try {
const { shell, prefix, postfix } = $;
useBash();
if (import_node_process2.default.platform === "win32") {
$.shell = true;
$.prefix = "";
$.postfix = "";
$.quote = import_util.quote;
} else {
useBash();
}
if ((0, import_util.isString)(shell)) $.shell = shell;
if ((0, import_util.isString)(prefix)) $.prefix = prefix;
if ((0, import_util.isString)(postfix)) $.postfix = postfix;
Expand Down
9 changes: 8 additions & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,14 @@ function setShell(n: string, ps = true) {

try {
const { shell, prefix, postfix } = $
useBash()
if (process.platform === 'win32') {
$.shell = true
$.prefix = ''
$.postfix = ''
$.quote = quote
} else {
useBash()
}
if (isString(shell)) $.shell = shell
if (isString(prefix)) $.prefix = prefix
if (isString(postfix)) $.postfix = postfix
Expand Down
12 changes: 6 additions & 6 deletions test/export.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('core', () => {
assert.equal(typeof core.bus.wrap, 'function', 'core.bus.wrap')
assert.equal(typeof core.cd, 'function', 'core.cd')
assert.equal(typeof core.chalk, 'function', 'core.chalk')
assert.equal(typeof core.chalk.level, 'number', 'core.chalk.level')
assert.equal(typeof core.chalk.level, 'undefined', 'core.chalk.level')
assert.equal(typeof core.defaults, 'object', 'core.defaults')
assert.equal(typeof core.defaults.detached, 'boolean', 'core.defaults.detached')
assert.equal(typeof core.defaults.env, 'object', 'core.defaults.env')
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('index', () => {
assert.equal(typeof index.bus.wrap, 'function', 'index.bus.wrap')
assert.equal(typeof index.cd, 'function', 'index.cd')
assert.equal(typeof index.chalk, 'function', 'index.chalk')
assert.equal(typeof index.chalk.level, 'number', 'index.chalk.level')
assert.equal(typeof index.chalk.level, 'undefined', 'index.chalk.level')
assert.equal(typeof index.defaults, 'object', 'index.defaults')
assert.equal(typeof index.defaults.detached, 'boolean', 'index.defaults.detached')
assert.equal(typeof index.defaults.env, 'object', 'index.defaults.env')
Expand Down Expand Up @@ -242,12 +242,15 @@ describe('index', () => {
assert.equal(typeof index.fs, 'object', 'index.fs')
assert.equal(typeof index.fs.Dir, 'function', 'index.fs.Dir')
assert.equal(typeof index.fs.Dirent, 'function', 'index.fs.Dirent')
assert.equal(typeof index.fs.F_OK, 'number', 'index.fs.F_OK')
assert.equal(typeof index.fs.FileReadStream, 'function', 'index.fs.FileReadStream')
assert.equal(typeof index.fs.FileWriteStream, 'function', 'index.fs.FileWriteStream')
assert.equal(typeof index.fs.R_OK, 'number', 'index.fs.R_OK')
assert.equal(typeof index.fs.ReadStream, 'function', 'index.fs.ReadStream')
assert.equal(typeof index.fs.Stats, 'function', 'index.fs.Stats')
assert.equal(typeof index.fs.Utf8Stream, 'function', 'index.fs.Utf8Stream')
assert.equal(typeof index.fs.W_OK, 'number', 'index.fs.W_OK')
assert.equal(typeof index.fs.WriteStream, 'function', 'index.fs.WriteStream')
assert.equal(typeof index.fs.X_OK, 'number', 'index.fs.X_OK')
assert.equal(typeof index.fs._toUnixTimestamp, 'function', 'index.fs._toUnixTimestamp')
assert.equal(typeof index.fs.access, 'function', 'index.fs.access')
assert.equal(typeof index.fs.accessSync, 'function', 'index.fs.accessSync')
Expand Down Expand Up @@ -303,8 +306,6 @@ describe('index', () => {
assert.equal(typeof index.fs.ftruncateSync, 'function', 'index.fs.ftruncateSync')
assert.equal(typeof index.fs.futimes, 'function', 'index.fs.futimes')
assert.equal(typeof index.fs.futimesSync, 'function', 'index.fs.futimesSync')
assert.equal(typeof index.fs.glob, 'function', 'index.fs.glob')
assert.equal(typeof index.fs.globSync, 'function', 'index.fs.globSync')
assert.equal(typeof index.fs.gracefulify, 'function', 'index.fs.gracefulify')
assert.equal(typeof index.fs.lchmod, 'function', 'index.fs.lchmod')
assert.equal(typeof index.fs.lchmodSync, 'function', 'index.fs.lchmodSync')
Expand All @@ -323,7 +324,6 @@ describe('index', () => {
assert.equal(typeof index.fs.mkdirs, 'function', 'index.fs.mkdirs')
assert.equal(typeof index.fs.mkdirsSync, 'function', 'index.fs.mkdirsSync')
assert.equal(typeof index.fs.mkdtemp, 'function', 'index.fs.mkdtemp')
assert.equal(typeof index.fs.mkdtempDisposableSync, 'function', 'index.fs.mkdtempDisposableSync')
assert.equal(typeof index.fs.mkdtempSync, 'function', 'index.fs.mkdtempSync')
assert.equal(typeof index.fs.move, 'function', 'index.fs.move')
assert.equal(typeof index.fs.moveSync, 'function', 'index.fs.moveSync')
Expand Down
42 changes: 42 additions & 0 deletions test/init-win32.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import assert from 'node:assert'
import { test } from 'node:test'
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)

test('$.shell defaults to true on win32', async () => {
const originalPlatform = process.platform

try {
Object.defineProperty(process, 'platform', {
value: 'win32',
configurable: true,
})

// Bust the cache to re-evaluate the core module initialization
const corePath = require.resolve('../build/core.js')
delete require.cache[corePath]

const { $ } = await import(`../build/core.js?update=${Date.now()}`)
assert.equal($.shell, true)
} finally {
Object.defineProperty(process, 'platform', {
value: originalPlatform,
configurable: true,
})
}
})