Comparing version 0.1.62 to 0.1.63
@@ -20,3 +20,3 @@ "use strict"; | ||
function isUserDefinedEntry(name) { | ||
if (typeof spackOptions.entry === 'string') { | ||
if (typeof spackOptions.entry === "string") { | ||
return spackOptions.entry === name; | ||
@@ -43,5 +43,5 @@ } | ||
await Object.keys(output).map(async (name)=>{ | ||
let fullPath = ''; | ||
let fullPath = ""; | ||
if (isUserDefinedEntry(name)) { | ||
fullPath = (0, _path.join)(spackOptions.output.path, spackOptions.output.name.replace('[name]', name)); | ||
fullPath = (0, _path.join)(spackOptions.output.path, spackOptions.output.name.replace("[name]", name)); | ||
} else { | ||
@@ -56,9 +56,9 @@ const ext = (0, _path.extname)(name); | ||
}); | ||
await write(fullPath, output[name].code, 'utf-8'); | ||
await write(fullPath, output[name].code, "utf-8"); | ||
if (output[name].map) { | ||
await write(`${fullPath}.map`, output[name].map, 'utf-8'); | ||
await write(`${fullPath}.map`, output[name].map, "utf-8"); | ||
} | ||
}); | ||
} else { | ||
throw new Error('Cannot print to stdout: not implemented yet'); | ||
throw new Error("Cannot print to stdout: not implemented yet"); | ||
} | ||
@@ -65,0 +65,0 @@ const emitEnd = process.hrtime(emitStart); |
@@ -62,6 +62,6 @@ "use strict"; | ||
_commander.default.option("--target [browser | node]", "Target runtime environment"); | ||
_commander.default.option('--context [path]', `The base directory (absolute path!) for resolving the 'entry'` + ` option. If 'output.pathinfo' is set, the included pathinfo is shortened to this directory`, 'The current directory'); | ||
_commander.default.option('--entry [list]', "List of entries", collect); | ||
_commander.default.option("--context [path]", `The base directory (absolute path!) for resolving the 'entry'` + ` option. If 'output.pathinfo' is set, the included pathinfo is shortened to this directory`, "The current directory"); | ||
_commander.default.option("--entry [list]", "List of entries", collect); | ||
// commander.option('-W --watch', `Enter watch mode, which rebuilds on file change.`) | ||
_commander.default.option('--debug', `Switch loaders to debug mode`); | ||
_commander.default.option("--debug", `Switch loaders to debug mode`); | ||
// commander.option('--devtool', `Select a developer tool to enhance debugging.`) | ||
@@ -77,4 +77,4 @@ // -d shortcut for --debug --devtool eval-cheap-module-source-map | ||
// Output options: | ||
_commander.default.option('-o --output', `The output path and file for compilation assets`); | ||
_commander.default.option('--output-path', `The output directory as **absolute path**`); | ||
_commander.default.option("-o --output", `The output path and file for compilation assets`); | ||
_commander.default.option("--output-path", `The output directory as **absolute path**`); | ||
// --output-filename Specifies the name of each output file on disk. | ||
@@ -198,3 +198,3 @@ // You must **not** specify an absolute path here! | ||
var _opts_config; | ||
const configOpts = await (0, _spack.compileBundleOptions)((_opts_config = opts.config) !== null && _opts_config !== void 0 ? _opts_config : _path.resolve('spack.config.js')); | ||
const configOpts = await (0, _spack.compileBundleOptions)((_opts_config = opts.config) !== null && _opts_config !== void 0 ? _opts_config : _path.resolve("spack.config.js")); | ||
if (opts.entry) { | ||
@@ -214,7 +214,7 @@ configOpts.entry = opts.entry; | ||
var _opts_outputPath; | ||
configOpts.output.path = (_opts_outputPath = opts.outputPath) !== null && _opts_outputPath !== void 0 ? _opts_outputPath : '[name].js'; | ||
configOpts.output.path = (_opts_outputPath = opts.outputPath) !== null && _opts_outputPath !== void 0 ? _opts_outputPath : "[name].js"; | ||
} | ||
if (!configOpts.output.name) { | ||
var _opts_output; | ||
configOpts.output.name = (_opts_output = opts.output) !== null && _opts_output !== void 0 ? _opts_output : '[name].js'; | ||
configOpts.output.name = (_opts_output = opts.output) !== null && _opts_output !== void 0 ? _opts_output : "[name].js"; | ||
} | ||
@@ -221,0 +221,0 @@ // if (!configOpts.output.name) { |
@@ -15,3 +15,3 @@ "use strict"; | ||
}); | ||
const fsMock = jest.createMockFromModule('fs'); | ||
const fsMock = jest.createMockFromModule("fs"); | ||
let mockStats = {}; | ||
@@ -18,0 +18,0 @@ function setMockStats(stats) { |
@@ -8,12 +8,12 @@ "use strict"; | ||
jest.mock("@swc/core"); | ||
describe('compile', ()=>{ | ||
describe("compile", ()=>{ | ||
it("compile with sync transform", async ()=>{ | ||
const options = {}; | ||
await (0, _compile.compile)('test.ts', options, true, undefined); | ||
expect(_core.transformFileSync).toHaveBeenCalledWith('test.ts', options); | ||
await (0, _compile.compile)("test.ts", options, true, undefined); | ||
expect(_core.transformFileSync).toHaveBeenCalledWith("test.ts", options); | ||
}); | ||
it("compile with async transform", async ()=>{ | ||
const options = {}; | ||
await (0, _compile.compile)('test.ts', options, false, undefined); | ||
expect(_core.transformFile).toHaveBeenCalledWith('test.ts', options); | ||
await (0, _compile.compile)("test.ts", options, false, undefined); | ||
expect(_core.transformFile).toHaveBeenCalledWith("test.ts", options); | ||
}); | ||
@@ -20,0 +20,0 @@ }); |
@@ -52,6 +52,6 @@ "use strict"; | ||
const createDefaultResult = ()=>({ | ||
"cliOptions": { | ||
"copyFiles": false, | ||
"deleteDirOnStart": false, | ||
"extensions": [ | ||
cliOptions: { | ||
copyFiles: false, | ||
deleteDirOnStart: false, | ||
extensions: [ | ||
".js", | ||
@@ -63,32 +63,34 @@ ".jsx", | ||
".ts", | ||
".tsx" | ||
".tsx", | ||
".cts", | ||
".mts" | ||
], | ||
// @ts-expect-error | ||
"filename": undefined, | ||
"filenames": [ | ||
filename: undefined, | ||
filenames: [ | ||
"src" | ||
], | ||
"includeDotfiles": false, | ||
includeDotfiles: false, | ||
// @ts-expect-error | ||
"outDir": undefined, | ||
outDir: undefined, | ||
// @ts-expect-error | ||
"outFile": undefined, | ||
"quiet": false, | ||
"sourceMapTarget": undefined, | ||
"sync": false, | ||
"watch": false | ||
outFile: undefined, | ||
quiet: false, | ||
sourceMapTarget: undefined, | ||
sync: false, | ||
watch: false | ||
}, | ||
"swcOptions": { | ||
"configFile": undefined, | ||
"jsc": { | ||
"parser": undefined, | ||
"transform": {} | ||
swcOptions: { | ||
configFile: undefined, | ||
jsc: { | ||
parser: undefined, | ||
transform: {} | ||
}, | ||
"sourceFileName": undefined, | ||
"sourceMaps": undefined, | ||
"sourceRoot": undefined, | ||
"swcrc": true | ||
sourceFileName: undefined, | ||
sourceMaps: undefined, | ||
sourceRoot: undefined, | ||
swcrc: true | ||
} | ||
}); | ||
describe('parserArgs', ()=>{ | ||
describe("parserArgs", ()=>{ | ||
let defaultResult; | ||
@@ -101,5 +103,5 @@ beforeEach(()=>{ | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'src' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"src" | ||
]; | ||
@@ -109,3 +111,3 @@ const result = await (0, _options.default)(args); | ||
}); | ||
describe('errors', ()=>{ | ||
describe("errors", ()=>{ | ||
let mockExit; | ||
@@ -115,4 +117,4 @@ let mockConsoleError; | ||
//@ts-expect-error | ||
mockExit = jest.spyOn(process, 'exit').mockImplementation(()=>{}); | ||
mockConsoleError = jest.spyOn(console, 'error').mockImplementation(()=>{}); | ||
mockExit = jest.spyOn(process, "exit").mockImplementation(()=>{}); | ||
mockConsoleError = jest.spyOn(console, "error").mockImplementation(()=>{}); | ||
}); | ||
@@ -127,6 +129,6 @@ beforeEach(()=>{ | ||
}); | ||
it('exits without filenames', async ()=>{ | ||
it("exits without filenames", async ()=>{ | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js" | ||
]; | ||
@@ -137,8 +139,8 @@ await (0, _options.default)(args); | ||
}); | ||
it('--watch exits without --out-dir', async ()=>{ | ||
it("--watch exits without --out-dir", async ()=>{ | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'src', | ||
'--watch' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"src", | ||
"--watch" | ||
]; | ||
@@ -149,9 +151,9 @@ await (0, _options.default)(args); | ||
}); | ||
it('--watch exits without filenames', async ()=>{ | ||
it("--watch exits without filenames", async ()=>{ | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'--watch', | ||
'--out-dir', | ||
'esm' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"--watch", | ||
"--out-dir", | ||
"esm" | ||
]; | ||
@@ -162,11 +164,11 @@ await (0, _options.default)(args); | ||
}); | ||
it('--out-dir exits with conflicting -out-file', async ()=>{ | ||
it("--out-dir exits with conflicting -out-file", async ()=>{ | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'src', | ||
'--out-file', | ||
'esm/index.js', | ||
'--out-dir', | ||
'esm' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"src", | ||
"--out-file", | ||
"esm/index.js", | ||
"--out-dir", | ||
"esm" | ||
]; | ||
@@ -178,9 +180,9 @@ await (0, _options.default)(args); | ||
}); | ||
describe('--source-maps', ()=>{ | ||
describe("--source-maps", ()=>{ | ||
it("source maps is ambiguous", async ()=>{ | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'src', | ||
'--source-maps' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"src", | ||
"--source-maps" | ||
]; | ||
@@ -197,7 +199,7 @@ const result = await (0, _options.default)(args); | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'--source-maps', | ||
'true', | ||
'src' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"--source-maps", | ||
"true", | ||
"src" | ||
]; | ||
@@ -214,7 +216,7 @@ const result = await (0, _options.default)(args); | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'-s', | ||
'inline', | ||
'src' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"-s", | ||
"inline", | ||
"src" | ||
]; | ||
@@ -224,3 +226,3 @@ const result = await (0, _options.default)(args); | ||
swcOptions: { | ||
sourceMaps: 'inline' | ||
sourceMaps: "inline" | ||
} | ||
@@ -231,9 +233,9 @@ }); | ||
}); | ||
describe('--config', ()=>{ | ||
describe("--config", ()=>{ | ||
it("throws with no config", async ()=>{ | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'src', | ||
'-C' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"src", | ||
"-C" | ||
]; | ||
@@ -244,7 +246,7 @@ expect(()=>(0, _options.default)(args)).toThrow(); | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'--config', | ||
'jsc.transform.react.development=true', | ||
'src' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"--config", | ||
"jsc.transform.react.development=true", | ||
"src" | ||
]; | ||
@@ -265,9 +267,9 @@ const result = await (0, _options.default)(args); | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'--config', | ||
'jsc.transform.react.development=true', | ||
'-C', | ||
'module.type=commonjs', | ||
'src' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"--config", | ||
"jsc.transform.react.development=true", | ||
"-C", | ||
"module.type=commonjs", | ||
"src" | ||
]; | ||
@@ -284,3 +286,3 @@ const result = await (0, _options.default)(args); | ||
module: { | ||
type: 'commonjs' | ||
type: "commonjs" | ||
} | ||
@@ -292,7 +294,7 @@ }); | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'--config', | ||
'jsc.transform.react.development=true,module.type=commonjs', | ||
'src' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"--config", | ||
"jsc.transform.react.development=true,module.type=commonjs", | ||
"src" | ||
]; | ||
@@ -309,3 +311,3 @@ const result = await (0, _options.default)(args); | ||
module: { | ||
type: 'commonjs' | ||
type: "commonjs" | ||
} | ||
@@ -317,7 +319,7 @@ }); | ||
const args = [ | ||
'node', | ||
'/path/to/node_modules/swc-cli/bin/swc.js', | ||
'--config', | ||
'no_equals', | ||
'src' | ||
"node", | ||
"/path/to/node_modules/swc-cli/bin/swc.js", | ||
"--config", | ||
"no_equals", | ||
"src" | ||
]; | ||
@@ -324,0 +326,0 @@ const result = await (0, _options.default)(args); |
@@ -71,3 +71,3 @@ "use strict"; | ||
}; | ||
const files = await Promise.all(sources.filter((source)=>includeDotfiles || !(0, _path.basename)(source).startsWith(".")).map((source)=>{ | ||
const files = await Promise.all(sources.filter((source)=>includeDotfiles || source === "." || !(0, _path.basename)(source).startsWith(".")).map((source)=>{ | ||
return new Promise((resolve)=>{ | ||
@@ -74,0 +74,0 @@ (0, _fs.stat)(source, (err, stat)=>{ |
{ | ||
"name": "@swc/cli", | ||
"version": "0.1.62", | ||
"version": "0.1.63", | ||
"description": "CLI for the swc project", | ||
@@ -60,3 +60,3 @@ "main": "lib/swc/index.js", | ||
"@swc/jest": "^0.1.2", | ||
"@types/jest": "^26.0.23", | ||
"@types/jest": "^29.5.0", | ||
"@types/node": "^12.19.16", | ||
@@ -66,7 +66,7 @@ "@types/semver": "^7.3.13", | ||
"deepmerge": "^4.2.2", | ||
"jest": "^27.0.3", | ||
"jest": "^29.5.0", | ||
"nano-staged": "^0.4.5", | ||
"prettier": "^2.5.1", | ||
"simple-git-hooks": "^2.7.0", | ||
"ts-jest": "^27.0.4", | ||
"ts-jest": "^29.0.5", | ||
"typescript": "~4.3.2" | ||
@@ -73,0 +73,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186132
2055