Skip to content

Commit 598e8f4

Browse files
committed
fix syncView problem when importing an example from task
1 parent 34c944e commit 598e8f4

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

edit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

3-
TUTORIAL_ROOT=/js/javascript-tutorial NODE_ENV=production gulp edit --harmony
3+
TUTORIAL_ROOT=/js/javascript-tutorial gulp edit --harmony
44

handlers/tutorial/tasks/importWatch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function watchTutorial(root) {
6161
function onTutorialModify(isDir, filePath) {
6262
if (~filePath.indexOf('___jb_')) return; // ignore JetBrains Webstorm tmp files
6363

64-
console.log("ImportWatch Modify " + filePath);
64+
log.debug("ImportWatch Modify " + filePath);
6565

6666
co(function* () {
6767

@@ -75,7 +75,7 @@ function watchTutorial(root) {
7575
yield* importer.sync(folder);
7676

7777
}).catch(function(err) {
78-
throw err;
78+
log.error(err);
7979
});
8080
}
8181

handlers/tutorial/tutorialImporter.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ TutorialImporter.prototype.sync = function* (directory) {
3434
var dir = fs.realpathSync(directory);
3535
var type;
3636
while (true) {
37-
if (dir.endsWith('.view')) {
37+
if (dir.endsWith('.view') && !dir.endsWith('/_js.view')) {
3838
type = 'View';
3939
break;
4040
}
@@ -63,8 +63,12 @@ TutorialImporter.prototype.sync = function* (directory) {
6363
var parentSlug = path.basename(parentDir);
6464
parentSlug = parentSlug.slice(parentSlug.indexOf('-') + 1);
6565

66-
var parent = yield Article.findOne({slug: parentSlug}).exec();
67-
66+
var parent;
67+
if (fs.existsSync(path.join(parentDir, 'task.md'))) {
68+
parent = yield Task.findOne({slug: parentSlug}).exec();
69+
} else {
70+
parent = yield Article.findOne({slug: parentSlug}).exec();
71+
}
6872
yield* this['sync' + type](dir, parent);
6973

7074
};
@@ -305,10 +309,11 @@ function* importImage(srcPath, dstDir) {
305309

306310
function copySync(srcPath, dstPath) {
307311
if (checkSameMtime(srcPath, dstPath)) {
312+
log.debug("copySync: same mtime %s = %s", srcPath, dstPath);
308313
return;
309314
}
310315

311-
log.debug("Copy %s to %s", srcPath, dstPath);
316+
log.debug("copySync %s -> %s", srcPath, dstPath);
312317

313318
fse.copySync(srcPath, dstPath);
314319
}
@@ -384,18 +389,15 @@ TutorialImporter.prototype.syncTask = function*(taskPath, parent) {
384389

385390
TutorialImporter.prototype.syncView = function*(dir, parent) {
386391

387-
log.info("syncView", dir);
388-
392+
log.info("syncView: dir", dir);
389393
var pathName = path.basename(dir).replace('.view', '');
390-
391394
if (pathName == '_js') {
392395
throw new Error("Must not syncView " + pathName);
393396
}
394397

395398
var webPath = parent.getResourceWebRoot() + '/' + pathName;
396399

397400
log.debug("syncView webpath", webPath);
398-
399401
var plunk = yield Plunk.findOne({webPath: webPath}).exec();
400402

401403
if (plunk) {

0 commit comments

Comments
 (0)