Skip to content

Commit b1a8d0e

Browse files
committed
chore: lintfixed
1 parent d217e38 commit b1a8d0e

File tree

4 files changed

+56
-59
lines changed

4 files changed

+56
-59
lines changed

scripts/postversion.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const platform = os.platform();
2020

2121
/* eslint-disable no-console */
2222
async function main() {
23-
console.error('Updating the package.json with optional native dependencies and package-lock.json');
23+
console.error(
24+
'Updating the package.json with optional native dependencies and package-lock.json',
25+
);
2426
const optionalDepsNative = [];
2527
for (const key in packageJSON.optionalDependencies) {
2628
if (key.startsWith(packageJSON.name)) {
@@ -35,18 +37,16 @@ async function main() {
3537
'--package-lock-only',
3638
'--save-optional',
3739
'--save-exact',
38-
...optionalDepsNative
40+
...optionalDepsNative,
3941
];
4042
console.error('Running npm install:');
4143
console.error(['npm', ...installArgs].join(' '));
42-
childProcess.execFileSync(
43-
'npm', installArgs, {
44-
stdio: ['inherit', 'inherit', 'inherit'],
45-
windowsHide: true,
46-
encoding: 'utf-8',
47-
shell: platform === 'win32' ? true : false,
48-
}
49-
);
44+
childProcess.execFileSync('npm', installArgs, {
45+
stdio: ['inherit', 'inherit', 'inherit'],
46+
windowsHide: true,
47+
encoding: 'utf-8',
48+
shell: platform === 'win32' ? true : false,
49+
});
5050
}
5151
}
5252
/* eslint-enable no-console */

scripts/prebuild.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async function main(argv = process.argv) {
4848
break;
4949
default:
5050
console.error('Unsupported architecture');
51-
process.exitCode = 1
51+
process.exitCode = 1;
5252
return process.exitCode;
5353
}
5454
let targetVendor;
@@ -68,18 +68,15 @@ async function main(argv = process.argv) {
6868
targetVendor = 'pc';
6969
targetSystem = 'windows';
7070
targetABI = 'msvc';
71-
break
71+
break;
7272
default:
7373
console.error('Unsupported platform');
7474
process.exitCode = 1;
7575
return process.exitCode;
7676
}
77-
const target = [
78-
targetArch,
79-
targetVendor,
80-
targetSystem,
81-
targetABI
82-
].filter((s) => s != null).join('-');
77+
const target = [targetArch, targetVendor, targetSystem, targetABI]
78+
.filter((s) => s != null)
79+
.join('-');
8380
const projectRoot = path.join(__dirname, '..');
8481
const prebuildPath = path.join(projectRoot, 'prebuild');
8582
await fs.promises.mkdir(prebuildPath, {
@@ -89,37 +86,37 @@ async function main(argv = process.argv) {
8986
const cargoTOML = await fs.promises.readFile(cargoTOMLPath, 'utf-8');
9087
const cargoTOMLVersion = cargoTOML.match(/version\s*=\s*"(.*)"/)?.[1];
9188
if (packageJSON.version !== cargoTOMLVersion) {
92-
console.error('Make sure that Cargo.toml version matches the package.json version');
89+
console.error(
90+
'Make sure that Cargo.toml version matches the package.json version',
91+
);
9392
process.exitCode = 1;
9493
return process.exitCode;
9594
}
9695
await fs.promises.writeFile(cargoTOMLPath, cargoTOML, { encoding: 'utf-8' });
9796
const buildPath = await fs.promises.mkdtemp(
98-
path.join(os.tmpdir(), 'prebuild-')
97+
path.join(os.tmpdir(), 'prebuild-'),
9998
);
10099
const buildArgs = [
101100
'build',
102101
buildPath,
103102
`--target=${target}`,
104-
...(production ? ['--release', '--strip']: [])
103+
...(production ? ['--release', '--strip'] : []),
105104
];
106105
console.error('Running napi build:');
107106
console.error(['napi', ...buildArgs].join(' '));
108-
childProcess.execFileSync(
109-
'napi', buildArgs, {
110-
stdio: ['inherit', 'inherit', 'inherit'],
111-
windowsHide: true,
112-
encoding: 'utf-8',
113-
shell: platform === 'win32' ? true : false,
114-
}
115-
);
107+
childProcess.execFileSync('napi', buildArgs, {
108+
stdio: ['inherit', 'inherit', 'inherit'],
109+
windowsHide: true,
110+
encoding: 'utf-8',
111+
shell: platform === 'win32' ? true : false,
112+
});
116113
// Rename to `name-platform-arch.node`
117114
const buildNames = await fs.promises.readdir(buildPath);
118115
const buildName = buildNames.find((filename) => /\.node$/.test(filename));
119116
const name = path.basename(buildName, '.node');
120117
await fs.promises.copyFile(
121118
path.join(buildPath, buildName),
122-
path.join(prebuildPath, `${name}-${platform}-${arch}.node`)
119+
path.join(prebuildPath, `${name}-${platform}-${arch}.node`),
123120
);
124121
await fs.promises.rm(buildPath, {
125122
recursive: true,

scripts/prepublishOnly.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ async function main(argv = process.argv) {
4646
const projectRoot = path.join(__dirname, '..');
4747
const prebuildPath = path.join(projectRoot, 'prebuild');
4848
const prepublishOnlyPath = path.join(projectRoot, 'prepublishOnly');
49-
const buildNames = (
50-
await fs.promises.readdir(prebuildPath)
51-
).filter((filename) => /^(?:[^-]+)-(?:[^-]+)-(?:[^-]+)$/.test(filename));
49+
const buildNames = (await fs.promises.readdir(prebuildPath)).filter(
50+
(filename) => /^(?:[^-]+)-(?:[^-]+)-(?:[^-]+)$/.test(filename),
51+
);
5252
if (buildNames.length < 1) {
5353
console.error(
54-
'You must prebuild at least 1 native object with the filename of `name-platform-arch` before prepublish'
54+
'You must prebuild at least 1 native object with the filename of `name-platform-arch` before prepublish',
5555
);
5656
process.exitCode = 1;
5757
return process.exitCode;
@@ -64,15 +64,15 @@ async function main(argv = process.argv) {
6464
// This is `@org/name-platform-arch`, uses `posix` to force usage of `/`
6565
const packageName = path.posix.join(orgName ?? '', name);
6666
const constraints = name.match(
67-
/^(?:[^-]+)-(?<platform>[^-]+)-(?<arch>[^-]+)$/
67+
/^(?:[^-]+)-(?<platform>[^-]+)-(?<arch>[^-]+)$/,
6868
);
6969
// This will be `prebuild/name-platform-arch.node`
7070
const buildPath = path.join(prebuildPath, buildName);
7171
// This will be `prepublishOnly/@org/name-platform-arch`
7272
const packagePath = path.join(prepublishOnlyPath, packageName);
7373
console.error('Packaging:', packagePath);
7474
await fs.promises.rm(packagePath, {
75-
recursive: true
75+
recursive: true,
7676
});
7777
await fs.promises.mkdir(packagePath, { recursive: true });
7878
const nativePackageJSON = {
@@ -86,31 +86,23 @@ async function main(argv = process.argv) {
8686
license: packageJSON.license,
8787
repository: packageJSON.repository,
8888
main: 'node.napi.node',
89-
os: [
90-
constraints.groups.platform
91-
],
92-
cpu: [
93-
...(constraints.groups.arch.split('+'))
94-
],
89+
os: [constraints.groups.platform],
90+
cpu: [...constraints.groups.arch.split('+')],
9591
};
9692
const packageJSONPath = path.join(packagePath, 'package.json');
9793
console.error(`Writing ${packageJSONPath}`);
9894
const packageJSONString = JSON.stringify(nativePackageJSON, null, 2);
9995
console.error(packageJSONString);
100-
await fs.promises.writeFile(
101-
packageJSONPath,
102-
packageJSONString,
103-
{
104-
encoding: 'utf8'
105-
}
106-
);
96+
await fs.promises.writeFile(packageJSONPath, packageJSONString, {
97+
encoding: 'utf8',
98+
});
10799
const packageBuildPath = path.join(packagePath, 'node.napi.node');
108100
console.error(`Copying ${buildPath} to ${packageBuildPath}`);
109101
await fs.promises.copyFile(buildPath, packageBuildPath);
110102
const publishArgs = [
111103
'publish',
112104
packagePath,
113-
...(tag != null ? [`--tag=${tag}`]: []),
105+
...(tag != null ? [`--tag=${tag}`] : []),
114106
'--access=public',
115107
...(dryRun ? ['--dry-run'] : []),
116108
];

src/native/quiche.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ const prebuildPath = path.join(projectRoot, 'prebuild');
5252
* try require on all npm targets second.
5353
*/
5454
function requireBinding(targets: Array<string>): Quiche {
55-
const prebuildTargets = targets.map((target) => `quic-${target}.node`);
55+
const prebuildTargets = targets.map((target) =>
56+
path.join(prebuildPath, `quic-${target}.node`),
57+
);
5658
for (const prebuildTarget of prebuildTargets) {
57-
const prebuildBindingPath = path.join(
58-
prebuildPath,
59-
prebuildTarget
60-
);
6159
try {
62-
return require(prebuildBindingPath);
60+
return require(prebuildTarget);
6361
} catch (e) {
6462
if (e.code !== 'MODULE_NOT_FOUND') throw e;
6563
}
@@ -73,7 +71,9 @@ function requireBinding(targets: Array<string>): Quiche {
7371
}
7472
}
7573
throw new Error(
76-
`Failed requiring possible native bindings: ${prebuildTargets.concat(npmTargets)}`
74+
`Failed requiring possible native bindings: ${prebuildTargets.concat(
75+
npmTargets,
76+
)}`,
7777
);
7878
}
7979

@@ -102,10 +102,18 @@ switch (process.platform) {
102102
case 'darwin':
103103
switch (process.arch) {
104104
case 'x64':
105-
nativeBinding = requireBinding(['darwin-x64', 'darwin-x64+arm64', 'darwin-arm64+x64']);
105+
nativeBinding = requireBinding([
106+
'darwin-x64',
107+
'darwin-x64+arm64',
108+
'darwin-arm64+x64',
109+
]);
106110
break;
107111
case 'arm64':
108-
nativeBinding = requireBinding(['darwin-arm64', 'darwin-arm64+x64', 'darwin-x64+arm64']);
112+
nativeBinding = requireBinding([
113+
'darwin-arm64',
114+
'darwin-arm64+x64',
115+
'darwin-x64+arm64',
116+
]);
109117
break;
110118
default:
111119
throw new Error(`Unsupported architecture on macOS: ${process.arch}`);

0 commit comments

Comments
 (0)