ghost 4.22.2 → 4.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,6 +2,7 @@ const Minifier = require('@tryghost/minifier');
|
|
|
2
2
|
const _ = require('lodash');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs').promises;
|
|
5
|
+
const logging = require('@tryghost/logging');
|
|
5
6
|
|
|
6
7
|
class CardAssetService {
|
|
7
8
|
constructor(options = {}) {
|
|
@@ -49,7 +50,14 @@ class CardAssetService {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
async minify(globs) {
|
|
52
|
-
|
|
53
|
+
try {
|
|
54
|
+
return await this.minifier.minify(globs);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
// @TODO: Convert this back to a proper error once the underlying bug is fixed
|
|
57
|
+
if (err.code === 'EACCES') {
|
|
58
|
+
logging.warn('Ghost was not able to write card asset files due to permissions.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
async clearFiles() {
|
|
@@ -59,8 +67,8 @@ class CardAssetService {
|
|
|
59
67
|
try {
|
|
60
68
|
await fs.unlink(path.join(this.dest, 'cards.min.css'));
|
|
61
69
|
} catch (error) {
|
|
62
|
-
// Don't worry if the file didn't exist
|
|
63
|
-
if (error.code !== 'ENOENT') {
|
|
70
|
+
// Don't worry if the file didn't exist or we don't have perms here
|
|
71
|
+
if (error.code !== 'ENOENT' && error.code !== 'EACCES') {
|
|
64
72
|
throw error;
|
|
65
73
|
}
|
|
66
74
|
}
|
|
@@ -68,8 +76,8 @@ class CardAssetService {
|
|
|
68
76
|
try {
|
|
69
77
|
await fs.unlink(path.join(this.dest, 'cards.min.js'));
|
|
70
78
|
} catch (error) {
|
|
71
|
-
// Don't worry if the file didn't exist
|
|
72
|
-
if (error.code !== 'ENOENT') {
|
|
79
|
+
// Don't worry if the file didn't exist or we don't have perms here
|
|
80
|
+
if (error.code !== 'ENOENT' && error.code !== 'EACCES') {
|
|
73
81
|
throw error;
|
|
74
82
|
}
|
|
75
83
|
}
|
|
@@ -94,7 +102,7 @@ class CardAssetService {
|
|
|
94
102
|
|
|
95
103
|
const globs = this.generateGlobs();
|
|
96
104
|
|
|
97
|
-
this.files = await this.minify(globs);
|
|
105
|
+
this.files = await this.minify(globs) || [];
|
|
98
106
|
}
|
|
99
107
|
}
|
|
100
108
|
|