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

Commit9d2077f

Browse files
committed
refactor out fileExists service for package
1 parent23cdb3b commit9d2077f

File tree

23 files changed

+32
-70
lines changed

23 files changed

+32
-70
lines changed

‎lib/modules/editor/actions/file.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
varfs_1=require('fs');
3-
varexists_1=require('../../../services/exists');
3+
varnode_file_exists_1=require('node-file-exists');
44
vareditor_1=require('./editor');
55
varopenTimeout=200;
66
functionopenFolder(){
@@ -14,13 +14,11 @@ exports.save = save;
1414
functionopen(filePath,options){
1515
if(options===void0){options={};}
1616
returnnewPromise(function(resolve,reject){
17-
if(exists_1.fileExists(filePath)){
17+
if(node_file_exists_1.default(filePath)){
1818
fs_1.unlink(filePath);
1919
}
2020
atom.workspace.open(filePath,options);
21-
setTimeout(function(){
22-
resolve();
23-
},openTimeout);
21+
setTimeout(function(){returnresolve();},openTimeout);
2422
});
2523
}
2624
exports.open=open;

‎lib/modules/setup/package-json/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"use strict";
22
varpath_1=require('path');
33
varfs_1=require('fs');
4-
varexists_1=require('../../../services/exists');
4+
varnode_file_exists_1=require('node-file-exists');
55
functionpackageJson(pj,action){
66
if(pj===void0){pj=null;}
77
switch(action.type){
88
case'SETUP_PACKAGE':
99
vardir=action.payload.dir;
1010
varpathToPackageJson=path_1.join(dir,'package.json');
11-
if(exists_1.fileExists(pathToPackageJson)){
11+
if(node_file_exists_1.default(pathToPackageJson)){
1212
returnJSON.parse(fs_1.readFileSync(pathToPackageJson,'utf8'));
1313
}
1414
returnnull;

‎lib/modules/tutorial/utils/config-paths.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
varpath_1=require('path');
3-
varsystem_1=require('../../../services/system');
3+
varsystem_1=require('./system');
44
functionconfigTestString(dir,name,config,testPath){
55
if(system_1.isWindows){
66
testPath=testPath.split('/').join('\\');
File renamed without changes.

‎lib/modules/tutorial/utils/tutorial-config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22
varpath_1=require('path');
3-
varexists_1=require('../../../services/exists');
4-
varsystem_1=require('../../../services/system');
3+
varnode_file_exists_1=require('node-file-exists');
4+
varsystem_1=require('./system');
55
functiontutorialConfig(tutorialPj,dir){
66
varconfig=tutorialPj.config,name=tutorialPj.name;
77
varrepo=loadRepo(tutorialPj.repo);
@@ -28,11 +28,11 @@ function loadRunner(name, runner, dir) {
2828
vartreeDep=path_1.join(dir,'node_modules',name,'node_modules',runner,'package.json');
2929
varrunnerMain;
3030
varrunnerRoot;
31-
if(exists_1.fileExists(flatDep)){
31+
if(node_file_exists_1.default(flatDep)){
3232
runnerMain=require(flatDep).main;
3333
runnerRoot=flatDep;
3434
}
35-
elseif(exists_1.fileExists(treeDep)){
35+
elseif(node_file_exists_1.default(treeDep)){
3636
runnerMain=require(treeDep).main;
3737
runnerRoot=treeDep;
3838
}

‎lib/modules/tutorials/utils/check.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22
varpath_1=require('path');
33
varfs_1=require('fs');
4-
varexists_1=require('../../../services/exists');
4+
varnode_file_exists_1=require('node-file-exists');
55
varis_tutorial_1=require('./is-tutorial');
66
varupdate_1=require('./update');
77
functionsearchForTutorials(dir,deps){
@@ -10,7 +10,7 @@ function searchForTutorials(dir, deps) {
1010
.filter(function(name){returnis_tutorial_1.isTutorial(dir,name);})
1111
.map(function(name){
1212
varpathToTutorialPackageJson=path_1.join(dir,'node_modules',name,'package.json');
13-
if(!exists_1.fileExists(pathToTutorialPackageJson)){
13+
if(!node_file_exists_1.default(pathToTutorialPackageJson)){
1414
console.log("Error with "+name+": no package.json file found. "+is_tutorial_1.tutorialError);
1515
return{
1616
name:name,

‎lib/modules/tutorials/utils/is-tutorial.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"use strict";
22
varpath_1=require('path');
33
varfs_1=require('fs');
4-
varexists_1=require('../../../services/exists');
4+
varnode_file_exists_1=require('node-file-exists');
55
exports.tutorialError='This is an error with the tutorial itself';
66
functionisTutorial(dir,name){
77
varpathToTutorialPackageJson=path_1.join(dir,'node_modules',name,'package.json');
8-
if(!exists_1.fileExists(pathToTutorialPackageJson)){
8+
if(!node_file_exists_1.default(pathToTutorialPackageJson)){
99
console.log("Error with "+name+": no package.json file found. "+exports.tutorialError);
1010
returnfalse;
1111
}
@@ -15,7 +15,7 @@ function isTutorial(dir, name) {
1515
returnfalse;
1616
}
1717
varpathToCoderoadJson=path_1.join(dir,'node_modules',name,packageJson.main);
18-
if(!exists_1.fileExists(pathToCoderoadJson)){
18+
if(!node_file_exists_1.default(pathToCoderoadJson)){
1919
console.log("Error with "+name+": no coderoad.json file. "+exports.tutorialError);
2020
returnfalse;
2121
}

‎lib/services/command-line.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"use strict";
2-
varexists_1=require('./exists');
2+
varnode_file_exists_1=require('node-file-exists');
33
varchild_process_1=require('child_process');
44
functioncommandLine(root,commands){
55
if(process.platform==='darwin'&&process.resourcesPath){
66
varlocalPath='/usr/local/bin/'+root;
77
varglobalPath='/usr/bin/'+root;
8-
if(exists_1.fileExists(localPath)){
8+
if(node_file_exists_1.default(localPath)){
99
root=localPath;
1010
}
11-
elseif(exists_1.fileExists(globalPath)){
11+
elseif(node_file_exists_1.default(globalPath)){
1212
root=globalPath;
1313
}
1414
else{

‎lib/services/exists.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"highlights":"1.3.1",
4242
"marked":"0.3.5",
4343
"material-ui":"0.15.0",
44+
"node-file-exists":"^1.0.0",
4445
"react":"15.0.2",
4546
"react-dom":"15.0.2",
4647
"react-redux":"4.4.5",

‎src/modules/editor/actions/file.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import{unlink}from'fs';
2-
import{fileExists}from'../../../services/exists';
2+
importfileExistsfrom'node-file-exists';
33
import{getEditor}from'./editor';
44

55
// delay necessary since opening a file is slow
@@ -19,9 +19,8 @@ export function open(filePath: string, options = {}): Promise<any> {
1919
if(fileExists(filePath)){
2020
unlink(filePath);
2121
}
22+
2223
atom.workspace.open(filePath,options);
23-
setTimeout(()=>{
24-
resolve();
25-
},openTimeout);
24+
setTimeout(()=>resolve(),openTimeout);
2625
});
2726
}

‎src/modules/setup/deps.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ components: ContentCard
22

33
atom
44

5-
services: commandLine, exists
5+
services: commandLine
66

77
tutorials/searchForTutorials
8+
editor/{open, set, openFolder, openTerminal}

‎src/modules/setup/package-json/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{join}from'path';
22
import{readFileSync}from'fs';
3-
import{fileExists}from'../../../services/exists';
3+
importfileExistsfrom'node-file-exists';
44

55
exportdefaultfunctionpackageJson(
66
pj=null,action:Action

‎src/modules/tutorial/deps.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
services/system
2-
services/exists
3-
41
actions: progressLoad, routeSet

‎src/modules/tutorial/utils/config-paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import{join}from'path';
2-
import{isWindows}from'../../../services/system';
2+
import{isWindows}from'./system';
33

44
functionconfigTestString(
55
dir:string,name:string,config:Tutorial.Config,testPath:string
File renamed without changes.

‎src/modules/tutorial/utils/tutorial-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{join}from'path';
2-
import{fileExists}from'../../../services/exists';
3-
import{isWindows}from'../../../services/system';
2+
importfileExistsfrom'node-file-exists';
3+
import{isWindows}from'./system';
44

55
exportfunctiontutorialConfig(
66
tutorialPj:PackageJson,dir:string

‎src/modules/tutorials/deps.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
services/exists
21
services/commandLine
32

43
actions: alertOpen, tutorialSet

‎src/modules/tutorials/utils/check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{join}from'path';
22
import{readFileSync}from'fs';
3-
import{fileExists}from'../../../services/exists';
3+
importfileExistsfrom'node-file-exists';
44
import{isTutorial,tutorialError}from'./is-tutorial';
55
import{canUpdateTutorial}from'./update';
66

‎src/modules/tutorials/utils/is-tutorial.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{join}from'path';
22
import{readFileSync}from'fs';
3-
import{fileExists}from'../../../services/exists';
3+
importfileExistsfrom'node-file-exists';
44

55
exportconsttutorialError='This is an error with the tutorial itself';
66

‎src/services/command-line.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{fileExists}from'./exists';
1+
importfileExistsfrom'node-file-exists';
22
import{exec}from'child_process';
33

44
exportdefaultfunctioncommandLine(root:string,

‎src/services/exists.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"src/modules/tutorial/reducer.ts",
120120
"src/modules/tutorial/types.ts",
121121
"src/modules/tutorial/utils/config-paths.ts",
122+
"src/modules/tutorial/utils/system.ts",
122123
"src/modules/tutorial/utils/tutorial-config.ts",
123124
"src/modules/tutorials/actions.ts",
124125
"src/modules/tutorials/index.ts",
@@ -133,9 +134,7 @@
133134
"src/modules/window/types.ts",
134135
"src/reducers.ts",
135136
"src/services/command-line.ts",
136-
"src/services/exists.ts",
137137
"src/services/polyfills.ts",
138-
"src/services/system.ts",
139138
"src/store.ts",
140139
"src/subscriptions.ts",
141140
"src/components/App.tsx",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp