Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ava/typescript

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ava/typescript - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

175

index.js

@@ -71,4 +71,10 @@ import fs from 'node:fs';

const changeInterpretations = Object.freeze(Object.assign(Object.create(null), {
unspecified: 0,
ignoreCompiled: 1,
waitForOutOfBandCompilation: 2,
}));
export default function typescriptProvider({negotiateProtocol}) {
const protocol = negotiateProtocol(['ava-3.2'], {version: pkg.version});
const protocol = negotiateProtocol(['ava-6', 'ava-3.2'], {version: pkg.version});
if (protocol === null) {

@@ -98,3 +104,141 @@ return;

const watchMode = protocol.identifier === 'ava-3.2'
? {
ignoreChange(filePath) {
if (!testFileExtension.test(filePath)) {
return false;
}
return rewritePaths.some(([from]) => filePath.startsWith(from));
},
resolveTestFile(testfile) { // Used under AVA 3.2 protocol by legacy watcher implementation.
if (!testFileExtension.test(testfile)) {
return testfile;
}
const rewrite = rewritePaths.find(([from]) => testfile.startsWith(from));
if (rewrite === undefined) {
return testfile;
}
const [from, to] = rewrite;
let newExtension = '.js';
if (testfile.endsWith('.cts')) {
newExtension = '.cjs';
} else if (testfile.endsWith('.mts')) {
newExtension = '.mjs';
}
return `${to}${testfile.slice(from.length)}`.replace(testFileExtension, newExtension);
},
}
: {
changeInterpretations,
interpretChange(filePath) {
if (config.compile === false) {
for (const [from] of rewritePaths) {
if (testFileExtension.test(filePath) && filePath.startsWith(from)) {
return changeInterpretations.waitForOutOfBandCompilation;
}
}
}
if (config.compile === 'tsc') {
for (const [, to] of rewritePaths) {
if (filePath.startsWith(to)) {
return changeInterpretations.ignoreCompiled;
}
}
}
return changeInterpretations.unspecified;
},
resolvePossibleOutOfBandCompilationSources(filePath) {
if (config.compile !== false) {
return null;
}
// Only recognize .cjs, .mjs and .js files.
if (!/\.(c|m)?js$/.test(filePath)) {
return null;
}
for (const [from, to] of rewritePaths) {
if (!filePath.startsWith(to)) {
continue;
}
const rewritten = `${from}${filePath.slice(to.length)}`;
const possibleExtensions = [];
if (filePath.endsWith('.cjs')) {
if (extensions.includes('cjs')) {
possibleExtensions.push({replace: /\.cjs$/, extension: 'cjs'});
}
if (extensions.includes('cts')) {
possibleExtensions.push({replace: /\.cjs$/, extension: 'cts'});
}
if (possibleExtensions.length === 0) {
return null;
}
}
if (filePath.endsWith('.mjs')) {
if (extensions.includes('mjs')) {
possibleExtensions.push({replace: /\.mjs$/, extension: 'mjs'});
}
if (extensions.includes('mts')) {
possibleExtensions.push({replace: /\.mjs$/, extension: 'mts'});
}
if (possibleExtensions.length === 0) {
return null;
}
}
if (filePath.endsWith('.js')) {
if (extensions.includes('js')) {
possibleExtensions.push({replace: /\.js$/, extension: 'js'});
}
if (extensions.includes('ts')) {
possibleExtensions.push({replace: /\.js$/, extension: 'ts'});
}
if (extensions.includes('tsx')) {
possibleExtensions.push({replace: /\.js$/, extension: 'tsx'});
}
if (possibleExtensions.length === 0) {
return null;
}
}
const possibleDeletedFiles = [];
for (const {replace, extension} of possibleExtensions) {
const possibleFilePath = rewritten.replace(replace, `.${extension}`);
// Pick the first file path that exists.
if (fs.existsSync(possibleFilePath)) {
return [possibleFilePath];
}
possibleDeletedFiles.push(possibleFilePath);
}
return possibleDeletedFiles;
}
return null;
},
};
return {
...watchMode,
async compile() {

@@ -115,31 +259,2 @@ if (compile === 'tsc') {

ignoreChange(filePath) {
if (!testFileExtension.test(filePath)) {
return false;
}
return rewritePaths.some(([from]) => filePath.startsWith(from));
},
resolveTestFile(testfile) { // Used under AVA 3.2 protocol by legacy watcher implementation.
if (!testFileExtension.test(testfile)) {
return testfile;
}
const rewrite = rewritePaths.find(([from]) => testfile.startsWith(from));
if (rewrite === undefined) {
return testfile;
}
const [from, to] = rewrite;
let newExtension = '.js';
if (testfile.endsWith('.cts')) {
newExtension = '.cjs';
} else if (testfile.endsWith('.mts')) {
newExtension = '.mjs';
}
return `${to}${testfile.slice(from.length)}`.replace(testFileExtension, newExtension);
},
updateGlobs({filePatterns, ignoredByWatcherPatterns}) {

@@ -146,0 +261,0 @@ return {

14

package.json
{
"name": "@ava/typescript",
"version": "4.0.0",
"version": "4.1.0",
"description": "TypeScript provider for AVA",
"engines": {
"node": ">=14.19 <15 || >=16.15 <17 || >=18"
"node": "^14.19 || ^16.15 || ^18 || ^20"
},

@@ -27,10 +27,10 @@ "files": [

"escape-string-regexp": "^5.0.0",
"execa": "^7.1.0"
"execa": "^7.1.1"
},
"devDependencies": {
"ava": "^5.2.0",
"c8": "^7.13.0",
"ava": "^5.3.1",
"c8": "^8.0.0",
"del": "^7.0.0",
"typescript": "^4.9.5",
"xo": "^0.53.1"
"typescript": "^5.1.3",
"xo": "^0.54.2"
},

@@ -37,0 +37,0 @@ "c8": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc