You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/03/30 07:48:14 UTC
[incubator-opendal] 01/01: chore(bindings/nodejs): Fix generated headers
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch fix-header
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 5160f6c8b05b7f25ab1574b676170e8a015884fa
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Thu Mar 30 15:47:50 2023 +0800
chore(bindings/nodejs): Fix generated headers
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
bindings/nodejs/benchmark/lib.js | 6 ++---
bindings/nodejs/generated.js | 36 +++++++++++++++++++++-------
bindings/nodejs/package.json | 4 ++--
bindings/nodejs/scripts/header.js | 49 +++++++++++++++++++++++++++++++++++++++
4 files changed, 81 insertions(+), 14 deletions(-)
diff --git a/bindings/nodejs/benchmark/lib.js b/bindings/nodejs/benchmark/lib.js
index 5d985dba..5df3c75d 100644
--- a/bindings/nodejs/benchmark/lib.js
+++ b/bindings/nodejs/benchmark/lib.js
@@ -55,7 +55,7 @@ const client = new S3Client({
module.exports.opendal = {
read: (path) => opendal.read(path),
- write: (path, data) => opendal.write(path, data)
+ write: (path, data) => opendal.write(path, data),
}
module.exports.s3 = {
@@ -73,7 +73,7 @@ module.exports.s3 = {
Bucket: bucket,
})
return client.send(command)
- }
+ },
}
-module.exports.testFiles = testFiles
\ No newline at end of file
+module.exports.testFiles = testFiles
diff --git a/bindings/nodejs/generated.js b/bindings/nodejs/generated.js
index 6d918d7b..bd094f42 100644
--- a/bindings/nodejs/generated.js
+++ b/bindings/nodejs/generated.js
@@ -81,7 +81,9 @@ switch (platform) {
case 'win32':
switch (arch) {
case 'x64':
- localFileExisted = existsSync(join(__dirname, 'opendal.win32-x64-msvc.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.win32-x64-msvc.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.win32-x64-msvc.node')
@@ -93,7 +95,9 @@ switch (platform) {
}
break
case 'ia32':
- localFileExisted = existsSync(join(__dirname, 'opendal.win32-ia32-msvc.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.win32-ia32-msvc.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.win32-ia32-msvc.node')
@@ -105,7 +109,9 @@ switch (platform) {
}
break
case 'arm64':
- localFileExisted = existsSync(join(__dirname, 'opendal.win32-arm64-msvc.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.win32-arm64-msvc.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.win32-arm64-msvc.node')
@@ -144,7 +150,9 @@ switch (platform) {
}
break
case 'arm64':
- localFileExisted = existsSync(join(__dirname, 'opendal.darwin-arm64.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.darwin-arm64.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.darwin-arm64.node')
@@ -178,7 +186,9 @@ switch (platform) {
switch (arch) {
case 'x64':
if (isMusl()) {
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-x64-musl.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-x64-musl.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-x64-musl.node')
@@ -189,7 +199,9 @@ switch (platform) {
loadError = e
}
} else {
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-x64-gnu.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-x64-gnu.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-x64-gnu.node')
@@ -203,7 +215,9 @@ switch (platform) {
break
case 'arm64':
if (isMusl()) {
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-arm64-musl.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-arm64-musl.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-arm64-musl.node')
@@ -214,7 +228,9 @@ switch (platform) {
loadError = e
}
} else {
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-arm64-gnu.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-arm64-gnu.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-arm64-gnu.node')
@@ -227,7 +243,9 @@ switch (platform) {
}
break
case 'arm':
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-arm-gnueabihf.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-arm-gnueabihf.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-arm-gnueabihf.node')
diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json
index 79fc7075..92009da7 100644
--- a/bindings/nodejs/package.json
+++ b/bindings/nodejs/package.json
@@ -60,8 +60,8 @@
},
"scripts": {
"artifacts": "napi artifacts",
- "build": "napi build --platform --release --js generated.js",
- "build:debug": "napi build --platform --js generated.js",
+ "build": "napi build --platform --release --js generated.js && node ./scripts/header.js",
+ "build:debug": "napi build --platform --js generated.js && node ./scripts/header.js",
"docs": "typedoc",
"format": "prettier --write .",
"prepublishOnly": "napi prepublish -t npm",
diff --git a/bindings/nodejs/scripts/header.js b/bindings/nodejs/scripts/header.js
new file mode 100644
index 00000000..fd10f52b
--- /dev/null
+++ b/bindings/nodejs/scripts/header.js
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://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.
+ */
+
+const fs = require('fs')
+
+let files = ['generated.js', 'index.d.ts']
+
+for (path of files) {
+ let data = fs.readFileSync(path, 'utf8')
+ fs.writeFileSync(
+ path,
+ `/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://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.
+ */
+
+` + data,
+ )
+}