Skip to content

Commit

Permalink
fix(renderer): handle block comment variants
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-ho committed Nov 29, 2018
1 parent 7af8c91 commit dca2d1e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ export function removeOldCopyright(source: string, commentRegexp: RegExp, cpRegE

export const xmlCommentRegexp = /\s*<!--([\s\S]*?)-->\s*/g

export const blockCommentRegexp = /\s*\/\*\*\s*\n([\S\s]*?)\*\/\s*/g
export const blockCommentRegexp = /\s*\/\*.*?\s*\n([\S\s]*?)\*\/\s*/g

export const yamlMultilineCommentRegexp = /\s*(#\s*[^\n]+\n){2,}\s*/g
14 changes: 14 additions & 0 deletions test/__baselines__/js/with-not-formal-jsdoc-copyright.1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (C) xxx Systems, Inc - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by John Doe <jdoe@heaven.com>, 1984
*
* From https://softwareengineering.stackexchange.com/a/68150/266765
*/

function add(a, b) {
return a + b;
}

module.exports = add;
14 changes: 14 additions & 0 deletions test/__baselines__/js/with-not-formal-jsdoc-copyright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (C) xxx Systems, Inc - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by John Doe <jdoe@heaven.com>, 1984
*
* From https://softwareengineering.stackexchange.com/a/68150/266765
*/

function add(a, b) {
return a + b;
}

module.exports = add;
15 changes: 15 additions & 0 deletions test/__sources__/js/with-not-formal-jsdoc-copyright.1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*------------------------
* Copyright (C) year God, Heaven - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the XYZ license, which unfortunately won't be
* written for another century.
*
* You should have received a copy of the XYZ license with
* this file. If not, please write to: God, or visit: Heaven.
*/

function add(a, b) {
return a + b;
}

module.exports = add;
15 changes: 15 additions & 0 deletions test/__sources__/js/with-not-formal-jsdoc-copyright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (C) year God, Heaven - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the XYZ license, which unfortunately won't be
* written for another century.
*
* You should have received a copy of the XYZ license with
* this file. If not, please write to: God, or visit: Heaven.
*/

function add(a, b) {
return a + b;
}

module.exports = add;
10 changes: 10 additions & 0 deletions test/javascript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ describe('javascript tests', () => {
await assertRenderEqual(render, 'js/with-same-copyright.js', 'basic.txt', 'identical')
})
})

describe('with not formal jsdoc like copyright', () => {
test('should update which start with `/*` but not `/**`', async () => {
await assertRenderEqual(render, 'js/with-not-formal-jsdoc-copyright.js', 'basic.txt', 'update')
})

test('should update which start with `/*-----------------`', async () => {
await assertRenderEqual(render, 'js/with-not-formal-jsdoc-copyright.1.js', 'basic.txt', 'update')
})
})
})

0 comments on commit dca2d1e

Please sign in to comment.