Skip to content

Commit

Permalink
test4
Browse files Browse the repository at this point in the history
  • Loading branch information
yisibl committed Aug 8, 2023
1 parent 147a83c commit 9e1ec66
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ jobs:
with:
node-version: ${{ matrix.node }}
check-latest: true
shell: bash

- name: Install
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -310,7 +309,6 @@ jobs:
node-version: ${{ matrix.node }}
check-latest: true
cache: yarn
shell: bash
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -348,7 +346,6 @@ jobs:
node-version: ${{ matrix.node }}
check-latest: true
cache: yarn
shell: bash
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -388,7 +385,6 @@ jobs:
with:
name: bindings-aarch64-unknown-linux-gnu
path: .
shell: bash
- name: List packages
run: ls -R .
shell: bash
Expand Down Expand Up @@ -425,7 +421,6 @@ jobs:
with:
name: bindings-aarch64-unknown-linux-musl
path: .
shell: bash
- name: List packages
run: ls -R .
shell: bash
Expand All @@ -447,9 +442,9 @@ jobs:
run: |
set -e
find /usr/share/fonts -name *.ttf
# apk add fontconfig
# fc-cache --force
# fc-list :lang=en
apk add fontconfig
fc-cache --force
fc-list :lang=en
apk add nodejs npm yarn
yarn test
test-linux-arm-gnueabihf-binding:
Expand All @@ -472,7 +467,6 @@ jobs:
with:
name: bindings-armv7-unknown-linux-gnueabihf
path: .
shell: bash
- name: List packages
run: ls -R .
shell: bash
Expand Down
33 changes: 26 additions & 7 deletions __test__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PathLike, promises as fs, readdirSync } from 'fs'
import { PathLike, promises as fs, readdirSync, statSync } from 'fs'
import { join } from 'path'

import test from 'ava'
Expand Down Expand Up @@ -287,13 +287,32 @@ test.only('The defaultFontFamily is not found in the OS and needs to be fallback
return false
}
}
const path1 = require('path').join('/usr/share/fonts')
const isExists = await checkFileExists(path1)
console.info(`Node.js 开始读取字体目录 ${path1}`, isExists)

function find_files(directoryPath: PathLike) {
// 获取目录下的所有文件和子目录
const items = readdirSync(directoryPath);

// 遍历每个文件或子目录
items.forEach(item => {
const itemPath = require('path').join(directoryPath, item);
const stats = statSync(itemPath);

if (stats.isFile()) {
// 处理文件
console.log('文件:', itemPath);
} else if (stats.isDirectory()) {
// 处理子目录,并递归遍历
console.log('目录:', itemPath);
find_files(itemPath);
}
});
}

const fontPath = require('path').join('/usr/share/fonts')
const isExists = await checkFileExists(fontPath)
console.info(`Node.js 开始读取字体目录 ${fontPath}`, isExists)
if (isExists) {
readdirSync(path1).forEach((file) => {
console.info(`获取到文件 ${file}`)
})
find_files(fontPath)
}

const resvg = new Resvg(svg, {
Expand Down

0 comments on commit 9e1ec66

Please sign in to comment.