Skip to content

Commit

Permalink
Change functions in file.ts as class (#239)
Browse files Browse the repository at this point in the history
Changed functions in file.ts as class based on rules for modules.

ISSUE=#227
  • Loading branch information
nadongguri authored and romandev committed Feb 27, 2018
1 parent e4ae329 commit c261c87
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
38 changes: 20 additions & 18 deletions core/base/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,26 @@

import * as fs from 'fs';

export async function read(path: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
fs.readFile(path, 'utf8', (error, data) => {
if (error) {
reject(error);
}
resolve(data);
export default class File {
public static async read(path: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
fs.readFile(path, 'utf8', (error, data) => {
if (error) {
reject(error);
}
resolve(data);
});
});
});
}

export async function write(path: string, data: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
fs.writeFile(path, data, 'utf8', (error) => {
if (error) {
reject(error);
}
resolve();
}
public static async write(path: string, data: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
fs.writeFile(path, data, 'utf8', (error) => {
if (error) {
reject(error);
}
resolve();
});
});
});
}
}

2 changes: 1 addition & 1 deletion core/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import * as file from 'core/base/file';
import file from 'core/base/file';
import * as types from 'core/types';
import * as webidl from 'webidl2';

Expand Down
2 changes: 1 addition & 1 deletion generator/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as mkdirp from 'mkdirp';
import * as nunjucks from 'nunjucks';
import * as path from 'path';

import * as file from '../core/base/file';
import file from '../core/base/file';
import DictionaryTypes from './parser/dictionary_types';
import EnumTypes from './parser/enum_types';
import IDLDefinition from './parser/idl_definition';
Expand Down
2 changes: 1 addition & 1 deletion generator/reader/simple_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import * as file from '../../core/base/file';
import file from '../../core/base/file';

export async function readAll(idl_files: string[]):
Promise<[string, string][]> {
Expand Down

0 comments on commit c261c87

Please sign in to comment.