-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add
updateLicense
to lb4 copyright
command
- Loading branch information
1 parent
abc6111
commit 535df04
Showing
8 changed files
with
281 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/cli | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
'use strict'; | ||
|
||
const fse = require('fs-extra'); | ||
const _ = require('lodash'); | ||
const {promisify} = require('util'); | ||
const glob = promisify(require('glob')); | ||
|
||
const defaultFS = { | ||
write: fse.writeFile, | ||
read: fse.readFile, | ||
writeJSON: fse.writeJson, | ||
readJSON: fse.readJson, | ||
exists: fse.exists, | ||
}; | ||
|
||
/** | ||
* List all JS/TS files | ||
* @param {string[]} paths - Paths to search | ||
*/ | ||
async function jsOrTsFiles(cwd, paths = []) { | ||
paths = [].concat(paths); | ||
let globs; | ||
if (paths.length === 0) { | ||
globs = [glob('**/*.{js,ts}', {nodir: true, follow: false, cwd})]; | ||
} else { | ||
globs = paths.map(p => { | ||
if (/\/$/.test(p)) { | ||
p += '**/*.{js,ts}'; | ||
} else if (!/[^*]\.(js|ts)$/.test(p)) { | ||
p += '/**/*.{js,ts}'; | ||
} | ||
return glob(p, {nodir: true, follow: false, cwd}); | ||
}); | ||
} | ||
paths = await Promise.all(globs); | ||
paths = _.flatten(paths); | ||
return _.filter(paths, /\.(js|ts)$/); | ||
} | ||
|
||
exports.FSE = defaultFS; | ||
exports.jsOrTsFiles = jsOrTsFiles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.