Skip to content

Commit 57d8767

Browse files
committed
Imprt/export syntax instead of requires
1 parent b13d0c1 commit 57d8767

File tree

8 files changed

+61
-73
lines changed

8 files changed

+61
-73
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
yarn-error.log
33
dist
4+
.vscode

src/clearing/cleaner.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const del = require('del')
2-
const path = require('path')
3-
const chalk = require('chalk')
4-
const ora = require('ora')
1+
import del from 'del'
2+
import path from 'path'
3+
import chalk from 'chalk'
4+
import ora from 'ora'
55

6-
class Cleaner {
6+
export default class Cleaner {
77
constructor() {
88
this.spinner = ora({
99
text: chalk.cyan('Cleaning app directory'),
@@ -19,5 +19,3 @@ class Cleaner {
1919
this.spinner.succeed(chalk.cyan('Cleaned app directory'))
2020
}
2121
}
22-
23-
module.exports = Cleaner

src/packaging/packager.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
const path = require('path')
2-
const ora = require('ora')
3-
const chalk = require('chalk')
1+
import path from 'path'
2+
import ora from 'ora'
3+
import chalk from 'chalk'
4+
import Checker from 'utils/checker'
5+
import Builder from 'building/builder'
6+
47
const electronBuilder = require('electron-builder')
5-
const Checker = require('utils/checker')
6-
const Builder = require('building/builder')
78

8-
class Packager {
9+
export default class Packager {
910
constructor(platform, environment, publish) {
1011
Checker.ensure()
1112
this.platform = platform
@@ -76,5 +77,3 @@ class Packager {
7677
})
7778
}
7879
}
79-
80-
module.exports = Packager

src/scaffolding/generator.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
const path = require('path')
2-
const childProcess = require('child_process')
3-
const chalk = require('chalk')
4-
const ejs = require('ejs')
5-
const fs = require('fs')
6-
const { classify, underscored } = require('underscore.string')
1+
import path from 'path'
2+
import childProcess from 'child_process'
3+
import chalk from 'chalk'
4+
import ejs from 'ejs'
5+
import fs from 'fs'
6+
import { classify, underscored } from 'underscore.string'
77

8-
const bozon = require('utils/bozon')
8+
import bozon from 'utils/bozon'
99

10-
const json = require('../../package.json')
10+
import json from '../../package.json'
1111

1212
const $ = path.join
1313

14-
class Generator {
14+
export default class Generator {
1515
constructor(name, options) {
1616
this.name = underscored(name)
1717
this.options = options
@@ -183,5 +183,3 @@ class Generator {
183183
bozon.log('')
184184
}
185185
}
186-
187-
module.exports = Generator

src/scaffolding/questioner.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
var inquirer = require('inquirer')
2-
var chalk = require('chalk')
3-
var { isBlank } = require('underscore.string')
1+
import inquirer from 'inquirer'
2+
import chalk from 'chalk'
3+
import { isBlank } from 'underscore.string'
44

5-
class Questioner {
5+
export default class Questioner {
66
constructor(options) {
77
this.name = options.name
88
}
@@ -39,5 +39,3 @@ class Questioner {
3939
})
4040
}
4141
}
42-
43-
module.exports = Questioner

src/starting/starter.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const bozon = require('../utils/bozon')
2-
const ora = require('ora')
3-
const chalk = require('chalk')
4-
const Checker = require('utils/checker')
5-
const Builder = require('building/builder')
1+
import bozon from '../utils/bozon'
2+
import ora from 'ora'
3+
import chalk from 'chalk'
4+
import Checker from 'utils/checker'
5+
import Builder from 'building/builder'
66

7-
class Starter {
7+
export default class Starter {
88
constructor(options) {
99
Checker.ensure()
1010
this.options = options
@@ -24,5 +24,3 @@ class Starter {
2424
})
2525
}
2626
}
27-
28-
module.exports = Starter

src/testing/test_runner.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const fs = require('fs')
2-
const ora = require('ora')
3-
const chalk = require('chalk')
4-
const utils = require('./utils')
5-
const Checker = require('utils/checker')
6-
const Packager = require('packaging/packager')
7-
const bozon = require('utils/bozon')
1+
import fs from 'fs'
2+
import ora from 'ora'
3+
import chalk from 'chalk'
4+
import { uniqFileExtensions } from './utils'
5+
import Checker from 'utils/checker'
6+
import Packager from 'packaging/packager'
7+
import bozon from 'utils/bozon'
88

9-
class TestRunner {
9+
export default class TestRunner {
1010
constructor(options) {
1111
Checker.ensure()
1212
this.compilers = {
@@ -69,7 +69,7 @@ class TestRunner {
6969

7070
filteredExtensions() {
7171
var array = []
72-
utils.uniqFileExtensions(this.specPath).forEach((extension) => {
72+
uniqFileExtensions(this.specPath).forEach((extension) => {
7373
if (Object.keys(this.compilers).indexOf(extension) !== -1) {
7474
array.push(extension)
7575
}
@@ -82,5 +82,3 @@ class TestRunner {
8282
this.specPath.match(/feature/)
8383
}
8484
}
85-
86-
module.exports = TestRunner

src/testing/utils.js

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
1-
var fs = require('fs')
2-
var path = require('path')
1+
import fs from 'fs'
2+
import path from 'path'
33

4-
module.exports.isFile = function (pathString) {
4+
const isFile = function (pathString) {
55
return fs.lstatSync(pathString).isFile()
66
}
77

8-
module.exports.readFileList = function (pathString, filelist) {
9-
var _this = this
10-
filelist = filelist || []
8+
const readFileList = function (pathString, filelist) {
9+
let list = filelist || []
1110

12-
var files = fs.readdirSync(pathString)
11+
const files = fs.readdirSync(pathString)
1312

1413
files.forEach(function (file) {
15-
var newPath = path.join(pathString, file)
14+
const newPath = path.join(pathString, file)
1615
if (fs.statSync(newPath).isDirectory()) {
17-
filelist = _this.readFileList(newPath, filelist)
16+
list = readFileList(newPath, filelist)
1817
} else {
19-
filelist.push(file)
18+
list.push(file)
2019
}
2120
})
22-
return filelist
21+
return list
2322
}
2423

25-
module.exports.extension = function (file) {
26-
var array = file.split('.')
24+
const extension = function (file) {
25+
const array = file.split('.')
2726
return array[array.length - 1]
2827
}
2928

30-
module.exports.uniqFileExtensions = function (pathString) {
31-
if (this.isFile(pathString)) {
32-
return [this.extension(pathString)]
29+
export const uniqFileExtensions = function (pathString) {
30+
if (isFile(pathString)) {
31+
return [extension(pathString)]
3332
} else {
34-
var _this = this
35-
var extensions = []
33+
const extensions = []
3634

37-
var fileList = this.readFileList(pathString)
35+
const fileList = readFileList(pathString)
3836
fileList.forEach(function (file) {
39-
var extension = _this.extension(file)
40-
if (extensions.indexOf(extension) === -1) {
41-
extensions.push(extension)
37+
const ext = extension(file)
38+
if (extensions.indexOf(ext) === -1) {
39+
extensions.push(ext)
4240
}
4341
})
4442
return extensions

0 commit comments

Comments
 (0)