Skip to content

Commit 2ed3716

Browse files
committed
added locked version
1 parent 0adb614 commit 2ed3716

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

.github/workflows/publish-to-master.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ jobs:
1212
uses: actions/checkout@v4
1313
with:
1414
ref: source
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
1519
- name: Build
1620
run: |
1721
npm ci

gulpfile.mjs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,23 @@ gulp.task('Iconfont', async () => {
8484
const iconfontModule = await import('gulp-iconfont');
8585

8686
// Extract the function - CommonJS modules use .default when imported via dynamic import()
87-
// Try .default first, then fallback to the module itself
88-
const iconfontFn = (typeof iconfontModule.default === 'function')
89-
? iconfontModule.default
90-
: (typeof iconfontModule === 'function' ? iconfontModule : iconfontModule.default || iconfontModule);
91-
87+
let iconfontFn = iconfontModule.default;
88+
if (typeof iconfontFn !== 'function') {
89+
iconfontFn = iconfontModule;
90+
}
9291
if (typeof iconfontFn !== 'function') {
9392
throw new Error(
9493
`gulp-iconfont is not a function. ` +
9594
`Got: ${typeof iconfontFn}, ` +
9695
`default: ${typeof iconfontModule.default}, ` +
97-
`module: ${typeof iconfontModule}`
96+
`module: ${typeof iconfontModule}, ` +
97+
`keys: ${Object.keys(iconfontModule).join(', ')}`
9898
);
9999
}
100100

101-
// Create options object - use plain object literal to ensure compatibility
101+
// Create options object with fontName as the first property to ensure it's present
102102
const iconfontOptions = {
103-
fontName: 'iconFont',
103+
fontName: 'iconFont', // Required by svgicons2svgfont
104104
prependUnicode: true,
105105
formats: ['ttf', 'eot', 'woff', 'svg'],
106106
normalize: true,
@@ -110,12 +110,13 @@ gulp.task('Iconfont', async () => {
110110
centerHorizontally: false,
111111
};
112112

113-
// Double-check fontName exists and is a string
114-
if (!iconfontOptions.fontName || typeof iconfontOptions.fontName !== 'string') {
115-
throw new Error(`fontName is required but got: ${iconfontOptions.fontName} (${typeof iconfontOptions.fontName})`);
113+
// Ensure fontName is a non-empty string
114+
if (!iconfontOptions.fontName || typeof iconfontOptions.fontName !== 'string' || iconfontOptions.fontName.length === 0) {
115+
throw new Error(`fontName must be a non-empty string, got: ${JSON.stringify(iconfontOptions.fontName)}`);
116116
}
117117

118118
// Call the function directly with options
119+
// The function signature is: function gulpFontIcon(options)
119120
return gulp
120121
.src(['assets/img/icons/*.svg'])
121122
.pipe(iconfontFn(iconfontOptions))

0 commit comments

Comments
 (0)