Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit835b2fd

Browse files
committed
remove error messages & loading duplicate tutorials
1 parent784dc6a commit835b2fd

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

‎lib/tutorials/find-tutorials.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function findTutorials(dir, deps) {
1010
.map(function(name){
1111
varpathToTutorialPackageJson=path_1.join(dir,'node_modules',name,'package.json');
1212
if(!node_file_exists_1.default(pathToTutorialPackageJson)){
13-
console.log("Error with "+name+": no package.json file found. "+is_tutorial_1.tutorialError);
13+
console.log("Error with "+name+": no package.json file found.");
1414
return{
1515
name:name,
1616
version:'NOT INSTALLED'

‎lib/tutorials/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ function tutorials(dir) {
88
console.log(chalk_1.red("No package.json available"));
99
returnnull;
1010
}
11+
varremoveDups={};
1112
return([]
1213
.concat(find_tutorials_1.default(dir,pj.dependencies))
13-
.concat(find_tutorials_1.default(dir,pj.devDependencies)));
14+
.concat(find_tutorials_1.default(dir,pj.devDependencies))
15+
.filter(function(tutorial){
16+
if(!removeDups.hasOwnProperty(tutorial.name)&&removeDups[tutorial.name]!==tutorial.version){
17+
removeDups[tutorial.name]=tutorial.version;
18+
returntrue;
19+
}
20+
returnfalse;
21+
}));
1422
}
1523
Object.defineProperty(exports,"__esModule",{value:true});
1624
exports.default=tutorials;

‎lib/tutorials/is-tutorial.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
varpath_1=require('path');
33
varfs_1=require('fs');
44
varnode_file_exists_1=require('node-file-exists');
5-
exports.tutorialError='This is an error with the tutorial itself';
65
functionisTutorial(dir,name){
76
varpathToTutorialPackageJson=path_1.join(dir,'node_modules',name,'package.json');
87
if(!node_file_exists_1.default(pathToTutorialPackageJson)){
9-
console.log("Error with "+name+": no package.json file found. "+exports.tutorialError);
108
returnfalse;
119
}
1210
varpj=JSON.parse(fs_1.readFileSync(pathToTutorialPackageJson,'utf8'));
@@ -15,12 +13,10 @@ function isTutorial(dir, name) {
1513
}
1614
varpathToCoderoadJson=path_1.join(dir,'node_modules',name,pj.main);
1715
if(!node_file_exists_1.default(pathToCoderoadJson)){
18-
console.log("Error with "+name+": no coderoad.json file. "+exports.tutorialError);
1916
returnfalse;
2017
}
2118
;
2219
if(!pj.config||!pj.config.runner){
23-
console.log("Error with "+name+": no test runner specified. "+exports.tutorialError);
2420
returnfalse;
2521
}
2622
returntrue;

‎src/tutorials/find-tutorials.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import{join}from'path';
22
import{readFileSync}from'fs';
33
importfileExistsfrom'node-file-exists';
4-
import{isTutorial,tutorialError}from'./is-tutorial';
4+
import{isTutorial}from'./is-tutorial';
55
// import {canUpdateTutorial} from './update';
66

77
exportdefaultfunctionfindTutorials(
@@ -20,7 +20,7 @@ export default function findTutorials(
2020
// no package.json
2121
if(!fileExists(pathToTutorialPackageJson)){
2222
console.log(
23-
`Error with${name}: no package.json file found.${tutorialError}`
23+
`Error with${name}: no package.json file found.`
2424
);
2525
return{
2626
name,

‎src/tutorials/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@ export default function tutorials(dir: string): string[] {
1010
returnnull;
1111
}
1212

13+
letremoveDups={};
14+
1315
return([]
1416
.concat(findTutorials(dir,pj.dependencies))
1517
.concat(findTutorials(dir,pj.devDependencies))
18+
.filter((tutorial)=>{
19+
if(!removeDups.hasOwnProperty(tutorial.name)&&removeDups[tutorial.name]!==tutorial.version){
20+
removeDups[tutorial.name]=tutorial.version;
21+
returntrue;
22+
}
23+
returnfalse;
24+
})
1625
);
1726
}

‎src/tutorials/is-tutorial.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import {join} from 'path';
22
import{readFileSync}from'fs';
33
importfileExistsfrom'node-file-exists';
44

5-
exportconsttutorialError='This is an error with the tutorial itself';
5+
//export const tutorialError = 'This is an error with the tutorial itself';
66

77
exportfunctionisTutorial(dir:string,name:string):boolean{
88
// has package.json
99
constpathToTutorialPackageJson=join(
1010
dir,'node_modules',name,'package.json'
1111
);
1212
if(!fileExists(pathToTutorialPackageJson)){
13-
console.log(`Error with${name}: no package.json file found.${tutorialError}`);
13+
//console.log(`Error with ${name}: no package.json file found. ${tutorialError}`);
1414
returnfalse;
1515
}
1616
// main path to coderoad.json
@@ -25,11 +25,11 @@ export function isTutorial(dir: string, name: string): boolean {
2525
dir,'node_modules',name,pj.main
2626
);
2727
if(!fileExists(pathToCoderoadJson)){
28-
console.log(`Error with${name}: no coderoad.json file.${tutorialError}`);
28+
//console.log(`Error with ${name}: no coderoad.json file. ${tutorialError}`);
2929
returnfalse;
3030
};
3131
if(!pj.config||!pj.config.runner){
32-
console.log(`Error with${name}: no test runner specified.${tutorialError}`);
32+
//console.log(`Error with ${name}: no test runner specified. ${tutorialError}`);
3333
returnfalse;
3434
}
3535

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp