Skip to content

Commit

Permalink
add lastfile feature
Browse files Browse the repository at this point in the history
  • Loading branch information
excaliburhan committed Sep 30, 2016
1 parent 0a8814c commit 8c13afc
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 23 deletions.
22 changes: 13 additions & 9 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ const nw = new NwBuilder({
version: '0.17.4',
})

nw.on('log', console.log)
module.exports = {
build() {
nw.on('log', console.log)

// Build returns a promise
nw.build()
.then(() => {
console.log('all done!')
})
.catch(err => {
console.error(err)
})
// Build returns a promise
nw.build()
.then(() => {
console.log('all done!')
})
.catch(err => {
console.error(err)
})
},
}
9 changes: 9 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const gulp = require('gulp')
const gulpLess = require('gulp-less')
const cleanCss = require('gulp-clean-css')
const concat = require('gulp-concat')
const del = require('del')
const nwBuild = require('./build.js')

const paths = {
js: './js/*.js',
Expand All @@ -29,4 +31,11 @@ gulp.task('reload', () => {
gulp.watch(paths.style, ['style'])
})

gulp.task('build', () => {
del('build/**')
.then(() => {
nwBuild.build()
})
})

gulp.task('default', ['reload'])
2 changes: 1 addition & 1 deletion htmlTmp.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</script>
</head>
<body>
<div class="test"></div>
<!-- <div class="test"></div> -->
<div id="ruler"></div>
<div id='body'>
<div id='line'>
Expand Down
24 changes: 19 additions & 5 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const tabOverride = require('tabOverride')
const editor = require('./editor.js')
const menu = require('./menu.js')
const qiniuUtil = require('./qiniuUtil.js')
const util = require('./util.js')
const system = require('../system.json')

const $ = global.$
Expand Down Expand Up @@ -42,11 +43,24 @@ module.exports = {
menu.initMenu()
$(() => {
// open lastFile
if (
system.lastFile && !fs.statSync(system.lastFile).isDirectory() &&
~system.lastFile.indexOf('.md')
) {
editor.loadFile(system.lastFile)
if (system.lastFile) {
try {
fs.statSync(system.lastFile, err => {
if (err) {
console.log(err)
util.setSystem({
lastFile: null,
})
} else if (~system.lastFile.indexOf('.md')) {
editor.loadFile(system.lastFile)
}
})
} catch (ex) {
console.log(ex)
util.setSystem({
lastFile: null,
})
}
}
// file associations
if (global.gui.App.argv.length > 0) {
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"description": "a markdown app via nwjs",
"scripts": {
"style": "gulp style",
"clean": "rimraf build",
"deploy": "node build.js",
"pack": "rimraf build && node build.js"
"build": "gulp build"
},
"keywords": [
"nwjs",
Expand All @@ -26,6 +24,7 @@
"plugin": true
},
"devDependencies": {
"del": "^2.2.2",
"eslint": "^3.4.0",
"eslint-config-airbnb": "^10.0.1",
"eslint-plugin-html": "^1.5.2",
Expand All @@ -36,8 +35,7 @@
"gulp-clean-css": "^2.0.13",
"gulp-concat": "^2.6.0",
"nw-builder": "^3.1.0",
"nw-dev": "^3.0.0",
"rimraf": "^2.5.4"
"nw-dev": "^3.0.0"
},
"dependencies": {
"emojify.js": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion pdfTmp.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lastFile":"/Users/Xcalibur/Downloads/3.md"}
{"lastFile":null}

0 comments on commit 8c13afc

Please sign in to comment.