diff --git a/.github/workflows/npm-publish.yaml b/.github/workflows/npm-publish.yaml new file mode 100644 index 0000000..7687181 --- /dev/null +++ b/.github/workflows/npm-publish.yaml @@ -0,0 +1,21 @@ +name: npm publish + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + + - run: yarn && yarn compile + + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml new file mode 100644 index 0000000..e3c0d4b --- /dev/null +++ b/.github/workflows/upload.yaml @@ -0,0 +1,45 @@ +name: Upload Assets + +on: + pull_request: {} + push: + branches: + - master + +jobs: + upload-assets: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v1 + + - name: Get yarn cache + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v1 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - run: yarn && yarn release + name: Build web assets + + - name: Deploy to server + id: deploy + uses: Pendect/action-rsyncer@v1.1.0 + env: + DEPLOY_KEY: ${{secrets.rsync_private_key}} + with: + flags: "-avzr --progress" + options: "" + ssh_options: "" + src: "dist/*" + dest: "rsync-user@fe.jimu.io:/web-assets/repo/${{ github.repository }}" + + - name: Display status from deploy + run: echo "${{ steps.deploy.outputs.status }}" diff --git a/cirru/comma.cirru b/cirru/comma.cirru index 0178725..71d9374 100644 --- a/cirru/comma.cirru +++ b/cirru/comma.cirru @@ -2,4 +2,4 @@ print (, a) a , b - , c (, d) \ No newline at end of file + , c (, d) diff --git a/package.json b/package.json index b1f492c..bf65a62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cirru-parser", - "version": "0.10.7", + "version": "0.10.8-a1", "description": "Cirru Parser in CoffeeScript", "main": "./lib/parser.js", "scripts": { @@ -12,7 +12,7 @@ "release-html": "env=release cirruscript template.cirru", "up": "yarn release && cp -r cirru dist/ && tiye-up", "compile": "coffee -o lib/ -bc src/", - "test": "cirru-script test.cirru" + "test": "cirruscript test.cirru" }, "author": "jiyinyiyong", "license": "MIT", diff --git a/src/parser.coffee b/src/parser.coffee index e4b4138..0767bc0 100644 --- a/src/parser.coffee +++ b/src/parser.coffee @@ -35,13 +35,16 @@ exports.pare = (code, filename) -> shorten res +prefixError = (state) -> + "#{state.path or "FILE"}(#{state.y}:#{state.x})" + # eof _escape_eof = (xs, buffer, state, code) -> - throw new Error "EOF in escape state" + throw new Error "#{prefixError(state)} EOF in escape state" _string_eof = (xs, buffer, state, code) -> - throw new Error "EOF in string state" + throw new Error "#{prefixError(state)} EOF in string state" _space_eof = (xs, buffer, state, code) -> xs @@ -59,7 +62,7 @@ _indent_eof = (xs, buffer, state, code) -> # escape _escape_newline = (xs, buffer, state, code) -> - throw new Error 'newline while escape' + throw new Error "#{prefixError(state)} newline while escape" _escape_n = (xs, buffer, state, code) -> state.x += 1 @@ -87,7 +90,7 @@ _string_backslash = (xs, buffer, state, code) -> [xs, buffer, state, code[1..]] _string_newline = (xs, buffer, state, code) -> - throw new Error 'newline in a string' + throw new Error "#{prefixError(state)} newline in a string" _string_quote = (xs, buffer, state, code) -> state.name = 'token' @@ -126,7 +129,7 @@ _space_close = (xs, buffer, state, code) -> state.nest -= 1 state.level -= 1 if state.nest < 0 - throw new Error 'close at space' + throw new Error "#{prefixError(state)} close at space" state.x += 1 [xs, buffer, state, code[1..]] @@ -173,7 +176,7 @@ _token_newline = (xs, buffer, state, code) -> [xs, buffer, state, code[1..]] _token_open = (xs, buffer, state, code) -> - throw new Error 'open parenthesis in token' + throw new Error "#{prefixError(state)} open parenthesis in token" _token_close = (xs, buffer, state, code) -> state.name = 'space' @@ -207,12 +210,12 @@ _indent_newilne = (xs, buffer, state, code) -> [xs, buffer, state, code[1..]] _indent_close = (xs, buffer, state, code) -> - throw new Error 'close parenthesis at indent' + throw new Error "#{prefixError(state)} close parenthesis at indent" _indent_else = (xs, buffer, state, code) -> state.name = 'space' if (state.indented % 2) is 1 - throw new Error 'odd indentation' + throw new Error "#{prefixError(state)} odd indentation" indented = state.indented / 2 diff = indented - state.indent @@ -238,7 +241,7 @@ parse = (xs, buffer, state, code) -> when 'escape' if eof then _escape_eof args... else switch char - when '\r', '\n' then _escape_newline args... + when '\r', '\n' then _escape_newline args... when 'n' then _escape_n args... when 't' then _escape_t args... else _escape_else args... @@ -246,14 +249,14 @@ parse = (xs, buffer, state, code) -> if eof then _string_eof args... else switch char when '\\' then _string_backslash args... - when '\r', '\n' then _string_newline args... + when '\r', '\n' then _string_newline args... when '"' then _string_quote args... else _string_else args... when 'space' if eof then _space_eof args... else switch char when ' ' then _space_space args... - when '\r', '\n' then _space_newline args... + when '\r', '\n' then _space_newline args... when '(' then _space_open args... when ')' then _space_close args... when '"' then _space_quote args... @@ -262,7 +265,7 @@ parse = (xs, buffer, state, code) -> if eof then _token_eof args... else switch char when ' ' then _token_space args... - when '\r', '\n' then _token_newline args... + when '\r', '\n' then _token_newline args... when '(' then _token_open args... when ')' then _token_close args... when '"' then _token_quote args... @@ -271,6 +274,6 @@ parse = (xs, buffer, state, code) -> if eof then _indent_eof args... else switch char when ' ' then _indent_space args... - when '\r', '\n' then _indent_newilne args... + when '\r', '\n' then _indent_newilne args... when ')' then _indent_close args... else _indent_else args...