This commit is contained in:
Tiệp Sunflower
2023-03-06 14:23:39 +07:00
commit aa9c76c82f
2234 changed files with 449471 additions and 0 deletions

27
node_modules/chrome/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,27 @@
*.iml
.idea/
.ipr
.iws
*~
~*
*.diff
*.patch
*.bak
.DS_Store
Thumbs.db
.project
.*proj
.svn/
*.swp
*.swo
*.log
*.sublime-project
*.sublime-workspace
node_modules/
dist/
tmp/
.spm-build
.buildpath
.settings
.yml
_site

15
node_modules/chrome/README.md generated vendored Normal file
View File

@@ -0,0 +1,15 @@
# README
Open chrome in shell
---
## Install & Usage
```
$ npm install chrome -g
```
```
$ chrome
```

26
node_modules/chrome/common.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var fs = require('fs')
var exec = require('child_process').exec
var path = require('path')
var plist = require('plist')
exports.find = function(id, cb) {
var pathQuery = 'mdfind "kMDItemCFBundleIdentifier=="' + id + '""'
exec(pathQuery, function (err, stdout) {
var loc = stdout.trim()
if (loc === '') {
loc = null
err = err || new Error('Not found.')
}
cb(err, loc)
})
}
exports.parseVersionByPlist = function(plPath, key, cb) {
if (!fs.existsSync(plPath)) {
cb(null)
} else {
var data = plist.parse(fs.readFileSync(plPath, 'utf8'))
cb(data[key])
}
}

45
node_modules/chrome/index.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/env node
var path = require('path')
var exeq = require('exeq')
var common = require('./common')
var chrome = {
getCommand: function() {
return this.path + '/Contents/MacOS/Google Chrome'
},
isExist: function(cb) {
var that = this
if (this.version) {
cb(true)
return
}
common.find('com.google.Chrome', function(err, p) {
if (err) {
cb(false)
return
}
that.path = p
var pl = path.join(p, 'Contents', 'Info.plist')
common.parseVersionByPlist(pl, 'KSVersion', function(v) {
if (!v) {
cb(false)
return
}
that.version = v
cb(true)
})
})
},
fixWhitespace: function(str) {
return /\s/g.test(str) ? '"' + str + '"' : str
}
}
chrome.isExist(function() {
exeq([chrome.getCommand()].concat(process.argv.slice(2)).map(chrome.fixWhitespace).join(' '))
.catch(function(err) {
console.error('Failed to open Google Chrome as intended', err)
process.exit(err.code || 13)
})
})

28
node_modules/chrome/package.json generated vendored Normal file
View File

@@ -0,0 +1,28 @@
{
"name": "chrome",
"version": "0.1.0",
"description": "Open chrome in shell",
"repository": {
"type": "git",
"url": "git@github.com:afc163/chrome.git"
},
"main": "index.js",
"bin": {
"chrome": "index.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "afc163 <afc163@gmail.com>",
"license": "ISC",
"dependencies": {
"exeq": "^2.2.0",
"plist": "^1.1.0"
},
"maintainers": [
{
"name": "afc163",
"email": "afc163@gmail.com"
}
]
}