Skip to content

Commit 2e301d3

Browse files
committed
fix(pack): 修复 assets 文件名更改后打包资源报错
1 parent 33c2ca4 commit 2e301d3

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

lib/models/Project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ var Project = function () {
410410
}), function (err) {
411411
var statsInfo = stats.toJson({ errorDetails: false });
412412

413-
process.stdout.write('\n' + '\x1b[90m' + '-------------------------- YKIT PACKED ASSETS -------------------------- ' + '\x1b[0m \n\n');
413+
process.stdout.write('\n-------------------------- YKIT PACKED ASSETS --------------------------\n\n');
414414

415415
if (statsInfo.errors.length > 0) {
416416
statsInfo.errors.map(function (err) {

lib/utils/fs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ exports.deleteFolderRecursive = function (filePath, remainRootDir) {
133133
};
134134

135135
exports.getFileSize = function (filename) {
136-
var stats = fs.statSync(filename);
136+
try {
137+
var stats = fs.statSync(filename);
137138

138-
return stats['size'] > 1024 ? (stats['size'] / 1024).toFixed(2) + ' KB' : stats['size'] + ' Bytes';
139+
return stats['size'] > 1024 ? (stats['size'] / 1024).toFixed(2) + ' KB' : stats['size'] + ' Bytes';
140+
} catch (err) {
141+
return null;
142+
}
139143
};

src/models/Project.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,7 @@ class Project {
382382
}), (err) => {
383383
let statsInfo = stats.toJson({ errorDetails: false });
384384

385-
process.stdout.write('\n' +
386-
'\x1b[90m' +
387-
'-------------------------- YKIT PACKED ASSETS -------------------------- ' +
388-
'\x1b[0m \n\n');
385+
process.stdout.write('\n-------------------------- YKIT PACKED ASSETS --------------------------\n\n');
389386

390387
if (statsInfo.errors.length > 0) {
391388
statsInfo.errors.map((err) => {

src/utils/fs.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,13 @@ exports.deleteFolderRecursive = function(filePath, remainRootDir) {
110110
};
111111

112112
exports.getFileSize = function(filename) {
113-
const stats = fs.statSync(filename);
113+
try {
114+
const stats = fs.statSync(filename);
114115

115-
return stats['size'] > 1024
116-
? (stats['size'] / 1024).toFixed(2) + ' KB'
117-
: stats['size'] + ' Bytes';
116+
return stats['size'] > 1024
117+
? (stats['size'] / 1024).toFixed(2) + ' KB'
118+
: stats['size'] + ' Bytes';
119+
} catch (err) {
120+
return null;
121+
}
118122
};

0 commit comments

Comments
 (0)