Skip to content

Commit

Permalink
try fixing #99
Browse files Browse the repository at this point in the history
  • Loading branch information
Diablohu committed Apr 18, 2019
1 parent 7081f01 commit 92df046
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"is-valid-path": "0.1.1",
"inquirer": "6.3.1",
"chalk": "2.4.2",
"latest-version": "5.1.0"
"latest-version": "5.1.0",
"crlf": "1.1.1"
}
}
3 changes: 2 additions & 1 deletion packages/koot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

## 0.9.0 (Alpha)
**2019-04-18** (alpha.5)
**2019-04-??** (alpha.6)
- 核心
- 配置项
- **** `devMemoryAllocation` - 指定开发环境中 node.js 分配的内存。详情请参见文档的 [配置](https://koot.js.org/#/config?id=devmemoryallocation) 章节
- 现在可以使用 `yarn` 安装并使用 _Koot.js_ ([#99](https://github.com/cmux/koot/issues/99))
- 渲染结果 (SSR & SPA)
- 结尾现在会附带 koot 版本信息作为 HTML 代码注释 ([#64](https://github.com/cmux/koot/issues/64))
- 如果 ejs 模板中缺少关键注入项 (`inject`),现在会自动添加 ([#81](https://github.com/cmux/koot/issues/81))
Expand Down
44 changes: 40 additions & 4 deletions publish.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
const fs = require('fs-extra')
const path = require('path')
const inquirer = require('inquirer')
const crlf = require('crlf')

const runScript = require('./libs/run-script')
const logWelcome = require('./libs/log/welcome')
const logAbort = require('./libs/log/abort')
const logFinish = require('./libs/log/finish')

const filesChangedFromCRLFtoLF = []

const prePublish = async () => {
const dirKoot = path.resolve(__dirname, './packages/koot')
const { bin } = await fs.readJson(path.resolve(dirKoot, 'package.json'))
for (const pathname of bin) {
const file = path.resolve(dirKoot, pathname)
await new Promise((resolve, reject) => {
crlf.set(file, 'LF', (err, endingType) => {
if (err) return reject(err)
if (endingType === 'CRLF')
filesChangedFromCRLFtoLF.push(file)
resolve(endingType)
})
})
}
}

const postPublish = async () => {
for (const file of filesChangedFromCRLFtoLF) {
await new Promise((resolve, reject) => {
crlf.set(file, 'CRLF', (err) => {
if (err) return reject(err)
resolve()
})
})
}
}

const run = async () => {

logWelcome('Publish')
Expand Down Expand Up @@ -79,13 +109,19 @@ const run = async () => {
return
}

const cmd = `lerna publish`
await prePublish()
await runScript(
`lerna publish`
+ ` --ignore-changes "packages/!(${selected.join('|')})/**"`
+ (tag ? ` --dist-tag ${tag}` : '')

await runScript(cmd)
)
await postPublish()

logFinish()
}

run().catch(e => console.error(e))
run()
.catch(async e => {
console.error(e)
await postPublish()
})

0 comments on commit 92df046

Please sign in to comment.