Skip to content

Commit

Permalink
style: eslint standard
Browse files Browse the repository at this point in the history
  • Loading branch information
lijialiang committed Aug 14, 2018
1 parent 4884114 commit 87c5b97
Show file tree
Hide file tree
Showing 25 changed files with 2,055 additions and 2,078 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Expand Up @@ -5,11 +5,12 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,11 @@
'use strict'

module.exports = {
parser: 'babel-eslint',
extends: [
'standard'
],
rules: {
'eqeqeq': 'off'
}
}
3 changes: 2 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,7 @@
## Unreleased

* [null]
* 升级 Babel@7.0.0-rc.1
* 修复 Yarn 安装方式下开发工作流浏览器兼容性问题

## 0.0.50 (August 9, 2018)

Expand Down
127 changes: 63 additions & 64 deletions build.js
@@ -1,94 +1,93 @@
'use strict';
'use strict'

const del = require('del');
const fs = require('fs-extra');
const path = require('path');
const del = require('del')
const fs = require('fs-extra')
const path = require('path')

const webpackEntry = require('./core/common/0_webpack_entry');
const webpackEntry = require('./core/common/0_webpack_entry')

const webpackOptions = require('./core/build/webpack.options');
const webpackRun = require('./core/build/webpack.run');
const gulp = require('./core/build/gulp');
const getShell = require('./core/common/get_shell');
const webpackOptions = require('./core/build/webpack.options')
const webpackRun = require('./core/build/webpack.run')
const gulp = require('./core/build/gulp')
const getShell = require('./core/common/get_shell')

const util = require('./util');
const util = require('./util')

const Messager = require('./messager');
const messager = new Messager( );
const Messager = require('./messager')
const messager = new Messager()

module.exports = async ( _config_ ) => {
let { shell, onlyRunShell } = _config_[ 'workflow.build' ];
module.exports = async (_config_) => {
let { shell, onlyRunShell } = _config_[ 'workflow.build' ]

if ( shell && shell.indexOf( './' ) === 0 ) {
shell = path.resolve( _config_.projectPath, shell );
}
if (shell && shell.indexOf('./') === 0) {
shell = path.resolve(_config_.projectPath, shell)
}

if ( shell && !fs.existsSync( shell ) ) {
messager.error( 'shell file undefined.' );
if (shell && !fs.existsSync(shell)) {
messager.error('shell file undefined.')

shell = void 0;
}
shell = void 0
}

const shellFunc = shell ? getShell( shell, _config_, messager ) : void 0;
const shellFunc = shell ? getShell(shell, _config_, messager) : void 0

if ( shell && shellFunc && shellFunc.init ) {
await shellFunc.init( _config_ );
}
if (shell && shellFunc && shellFunc.init) {
await shellFunc.init(_config_)
}

// common config reslove
let config = require('./core/common/common_config')( _config_, messager );
// common config reslove
let config = require('./core/common/common_config')(_config_, messager)

const entryFiles = webpackEntry( config );
const entryFiles = webpackEntry(config)

config.entry = entryFiles;
config.entry = entryFiles

config.banner = `
config.banner = `
/*!
* ${ config.name }
* @version: ${ config.version }
* @author: ${ config.user }
* @update: ${ config.buildTime }
* ${config.name}
* @version: ${config.version}
* @author: ${config.user}
* @update: ${config.buildTime}
*/
`;

try {
del.sync( `${ config.path }/dist`, { force: true } );
`

webpackOptions( config );
try {
del.sync(`${config.path}/dist`, { force: true })

if ( shell && shellFunc && shellFunc.before ) {
await shellFunc.before( config );
}
webpackOptions(config)

if ( shell && onlyRunShell && shellFunc ) {
shellFunc.after ? await shellFunc.after( ) : await shellFunc( );
if (shell && shellFunc && shellFunc.before) {
await shellFunc.before(config)
}

return void 0;
}
if (shell && onlyRunShell && shellFunc) {
shellFunc.after ? await shellFunc.after() : await shellFunc()

fs.mkdirSync( `${ config.path }/dist` );
return void 0
}

config.mode !== 'webpack' && fs.mkdirSync( `${ config.path }/dist/img` );
config.mode !== 'webpack' && fs.mkdirSync( `${ config.path }/dist/css` );
config.mode !== 'webpack' && fs.mkdirSync( `${ config.path }/dist/js` );
fs.mkdirSync(`${config.path}/dist`)

await webpackRun( config, messager );
config.mode !== 'webpack' && fs.mkdirSync(`${config.path}/dist/img`)
config.mode !== 'webpack' && fs.mkdirSync(`${config.path}/dist/css`)
config.mode !== 'webpack' && fs.mkdirSync(`${config.path}/dist/js`)

config.mode !== 'webpack' && await gulp( config, messager );
await webpackRun(config, messager)

if ( shell && shellFunc ) {
shellFunc.after ? await shellFunc.after( config ) : ( typeof shellFunc === 'function' && await shellFunc( config ) );
}
else {
messager.success( );
}
config.mode !== 'webpack' && await gulp(config, messager)

if ( config.autoOpenChrome ) {
util.chromeOpen( `${ config.projectPath }/dist` );
}
} catch ( err ) {
console.error( '[BUILD@WEBPACK ERROR]', err );
if (shell && shellFunc) {
shellFunc.after ? await shellFunc.after(config) : (typeof shellFunc === 'function' && await shellFunc(config))
} else {
messager.success()
}

messager.error( err );
if (config.autoOpenChrome) {
util.chromeOpen(`${config.projectPath}/dist`)
}
} catch (err) {
console.error('[BUILD@WEBPACK ERROR]', err)

messager.error(err)
}
}

0 comments on commit 87c5b97

Please sign in to comment.