Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit bdc674b

Browse files
committed
index.js: fix sync problem and image copy problem
Issue: #22 Signed-off-by: Huang Rui <vowstar@gmail.com>
1 parent 731023b commit bdc674b

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ function processBlock(blk) {
7777
var destFilePath = path.join(rootPath, ASSET_PATH);
7878
if (fs.existsSync(ASSET_PATH)) {
7979
if (!fs.existsSync(destFilePath)) {
80-
fs.mkdirs(path.join(rootPath, ASSET_PATH));
80+
fs.mkdirSync(path.join(rootPath, ASSET_PATH), { recursive: true });
81+
}
82+
// NOTE: fix https://github.com/vowstar/gitbook-plugin-uml/issues/22
83+
// When destFilePath exist, file should copied
84+
if (fs.existsSync(destFilePath)) {
8185
fs.copySync(ASSET_PATH, path.join(rootPath, ASSET_PATH));
8286
}
8387
} else {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
"test": "nyc --reporter=lcov mocha --reporter spec --timeout 200000",
5353
"coverage": "cat ./coverage/lcov.info | coveralls"
5454
},
55-
"version": "1.2.10"
55+
"version": "1.2.11"
5656
}

test/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,21 @@ describe('uml', function() {
154154
assert(result.get(targetFile).content.includes('<polygon fill'), true);
155155
});
156156
});
157+
it('should correctly generate multi puml file', function() {
158+
return tester.builder()
159+
.withContent('\n```puml\n@startuml\n(A)->(B)\n@enduml\n```\nHello\n```puml\n@startuml\n(C)->(D)\n@enduml\n```')
160+
.withLocalPlugin(path.join(__dirname, '..'))
161+
.withBookJson({
162+
plugins: ['uml']
163+
})
164+
.create()
165+
.then(function(result) {
166+
var targetFile = 'assets/images/uml/39e6cfed5bc41c359e02bb07bcfcbcb365bd61eb.svg';
167+
assert(result.get('index.html').content.includes(targetFile), true);
168+
assert(result.get(targetFile).content.includes('<polygon fill'), true);
169+
targetFile = 'assets/images/uml/b8d9c8ad9d60d1889365be04217e700042cabc04.svg';
170+
assert(result.get('index.html').content.includes(targetFile), true);
171+
assert(result.get(targetFile).content.includes('<polygon fill'), true);
172+
});
173+
});
157174
});

0 commit comments

Comments
 (0)