Skip to content

Commit a8ff848

Browse files
committed
fix: convert require() to ESM imports in scripts and fix unused expressions
1 parent d25a21a commit a8ff848

2 files changed

Lines changed: 10 additions & 34 deletions

File tree

scripts/tag.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,12 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License.
1414
*/
15-
16-
'use strict';
17-
18-
const semver = require('semver');
15+
import semver from "semver";
1916
const targetVersion = process.argv[2];
20-
2117
if (!semver.valid(targetVersion)) {
2218
console.error(`Error: the version "${targetVersion}" is invalid!`);
2319
process.exit(1);
2420
}
25-
2621
const prerelease = semver.prerelease(targetVersion);
27-
const tag = prerelease ? 'unstable' : 'latest';
28-
22+
const tag = prerelease ? "unstable" : "latest";
2923
console.log(`::set-output name=tag::--tag=${tag}`);

scripts/updateRuntimeDependencies.js

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
const { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } = require('fs');
15-
const tar = require('tar');
16-
const path = require('path');
14+
import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } from 'fs';
1715

18-
function ensureDirSync(path) {
19-
!existsSync(path) && mkdirSync(path, { recursive: true });
16+
function ensureDirSync(dirPath) {
17+
if (!existsSync(dirPath)) { mkdirSync(dirPath, { recursive: true }); }
2018
}
21-
22-
function removeSync(path) {
23-
rmSync(path, { recursive: true, force: true });
19+
function removeSync(dirPath) {
20+
rmSync(dirPath, { recursive: true, force: true });
2421
}
25-
2622
const HEADER = `/*
2723
* Licensed under the Apache License, Version 2.0 (the "License");
2824
* you may not use this file except in compliance with the License.
@@ -36,32 +32,18 @@ const HEADER = `/*
3632
* See the License for the specific language governing permissions and
3733
* limitations under the License.
3834
*/
39-
4035
/* eslint-disable quotes */
4136
// file generated by ./scripts/updateRuntimeDependencies.js
4237
`;
43-
44-
/**
45-
* Package the TypeScript declarations for dayjs, jsonpath and SmartLegalContract
46-
* These are needed at runtime to compile user TypeScript code and template logic to JS
47-
*/
48-
const dayjs = readFileSync('./node_modules/dayjs/index.d.ts').toString(
49-
'base64'
50-
);
51-
const jsonpath = readFileSync(
52-
'./node_modules/@types/jsonpath/index.d.ts'
53-
).toString('base64');
54-
const smartLegalContract = readFileSync(
55-
'./src/slc/SmartLegalContract.d.ts'
56-
).toString('base64');
57-
38+
const dayjs = readFileSync('./node_modules/dayjs/index.d.ts').toString('base64');
39+
const jsonpath = readFileSync('./node_modules/@types/jsonpath/index.d.ts').toString('base64');
40+
const smartLegalContract = readFileSync('./src/slc/SmartLegalContract.d.ts').toString('base64');
5841
removeSync('./src/runtime/');
5942
ensureDirSync('./src/runtime/');
6043
writeFileSync(
6144
'./src/runtime/declarations.ts',
6245
`
6346
${HEADER}
64-
6547
export const DAYJS_BASE64 = '${dayjs}';
6648
export const JSONPATH_BASE64 = '${jsonpath}';
6749
export const SMART_LEGAL_CONTRACT_BASE64 = '${smartLegalContract}';

0 commit comments

Comments
 (0)