Socket
Socket
Sign inDemoInstall

@blockforfun/plugin-git

Package Overview
Dependencies
156
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.2.0 to 4.2.1

src/git-out-command.js

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [4.2.1](https://github.com/blockforfun/cli/compare/@blockforfun/plugin-git@4.2.0...@blockforfun/plugin-git@4.2.1) (2018-12-09)
**Note:** Version bump only for package @blockforfun/plugin-git
# [4.2.0](https://github.com/blockforfun/cli/compare/@blockforfun/plugin-git@4.1.0...@blockforfun/plugin-git@4.2.0) (2018-12-09)

@@ -8,0 +16,0 @@

2

oclif.manifest.json

@@ -1,1 +0,1 @@

{"version":"4.2.0","commands":{"delete:json":{"id":"delete:json","description":"deletes entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["rm:json","del:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"delete:text":{"id":"delete:text","description":"deletes entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["rm","del","rm:text","del:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"list:json":{"id":"list:json","description":"lists entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["ls:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"output","description":"output file path"}]},"list:text":{"id":"list:text","description":"lists entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["ls","ls:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"output","description":"output file path"}]},"read:json":{"id":"read:json","description":"reads entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["get:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"read:text":{"id":"read:text","description":"reads entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["get","get:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"write:json":{"id":"write:json","description":"writes entries in json format to a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["put:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"input","description":"input file path","required":true}]},"write:text":{"id":"write:text","description":"writes entries in text format to a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["put","put:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"input","description":"input file path","required":true}]}}}
{"version":"4.2.1","commands":{"delete:json":{"id":"delete:json","description":"deletes entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["rm:json","del:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"delete:text":{"id":"delete:text","description":"deletes entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["rm","del","rm:text","del:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"list:json":{"id":"list:json","description":"lists entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["ls:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"output","description":"output file path"}]},"list:text":{"id":"list:text","description":"lists entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["ls","ls:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"output","description":"output file path"}]},"read:json":{"id":"read:json","description":"reads entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["get:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"read:text":{"id":"read:text","description":"reads entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["get","get:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"write:json":{"id":"write:json","description":"writes entries in json format to a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["put:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"input","description":"input file path","required":true}]},"write:text":{"id":"write:text","description":"writes entries in text format to a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["put","put:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"input","description":"input file path","required":true}]}}}
{
"name": "@blockforfun/plugin-git",
"description": "BlockFor.fun CLI git plugin",
"version": "4.2.0",
"version": "4.2.1",
"author": "Mikael Karon <mikael@karon.se>",

@@ -74,3 +74,3 @@ "bugs": "https://github.com/blockforfun/cli/issues",

},
"gitHead": "b8b9fe5c518cd157f39d77d72c34e2e68a7c24de"
"gitHead": "b1307dc660e4d9876dc177a1589abe01287ba360"
}

@@ -25,3 +25,3 @@ @blockforfun/plugin-git

$ oclif-example (-v|--version|version)
@blockforfun/plugin-git/4.2.0 win32-x64 node-v10.10.0
@blockforfun/plugin-git/4.2.1 win32-x64 node-v10.10.0
$ oclif-example --help [COMMAND]

@@ -69,3 +69,3 @@ USAGE

_See code: [src\commands\delete\json.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\delete\json.js)_
_See code: [src\commands\delete\json.js](https://github.com/blockforfun/cli/blob/v4.2.1/src\commands\delete\json.js)_

@@ -97,3 +97,3 @@ ## `oclif-example delete:text SOURCE PATH [OUTPUT]`

_See code: [src\commands\delete\text.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\delete\text.js)_
_See code: [src\commands\delete\text.js](https://github.com/blockforfun/cli/blob/v4.2.1/src\commands\delete\text.js)_

@@ -121,3 +121,3 @@ ## `oclif-example list:json SOURCE [OUTPUT]`

_See code: [src\commands\list\json.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\list\json.js)_
_See code: [src\commands\list\json.js](https://github.com/blockforfun/cli/blob/v4.2.1/src\commands\list\json.js)_

@@ -146,3 +146,3 @@ ## `oclif-example list:text SOURCE [OUTPUT]`

_See code: [src\commands\list\text.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\list\text.js)_
_See code: [src\commands\list\text.js](https://github.com/blockforfun/cli/blob/v4.2.1/src\commands\list\text.js)_

@@ -171,3 +171,3 @@ ## `oclif-example read:json SOURCE PATH [OUTPUT]`

_See code: [src\commands\read\json.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\read\json.js)_
_See code: [src\commands\read\json.js](https://github.com/blockforfun/cli/blob/v4.2.1/src\commands\read\json.js)_

@@ -197,3 +197,3 @@ ## `oclif-example read:text SOURCE PATH [OUTPUT]`

_See code: [src\commands\read\text.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\read\text.js)_
_See code: [src\commands\read\text.js](https://github.com/blockforfun/cli/blob/v4.2.1/src\commands\read\text.js)_

@@ -222,3 +222,3 @@ ## `oclif-example write:json SOURCE PATH INPUT`

_See code: [src\commands\write\json.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\write\json.js)_
_See code: [src\commands\write\json.js](https://github.com/blockforfun/cli/blob/v4.2.1/src\commands\write\json.js)_

@@ -248,3 +248,3 @@ ## `oclif-example write:text SOURCE PATH INPUT`

_See code: [src\commands\write\text.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\write\text.js)_
_See code: [src\commands\write\text.js](https://github.com/blockforfun/cli/blob/v4.2.1/src\commands\write\text.js)_
<!-- commandsstop -->

@@ -5,13 +5,8 @@ const DeleteTextCommand = require('./text')

class DeleteJsonCommand extends DeleteTextCommand {
async delete(repo, source, path, options) {
const {ref, output} = options
try {
const out = output ? message => output.write(`${message}\n`) : this.log
await this.mount(repo, source, options)
out(await repo.saveEntry(ref, parse(path, null, options), options))
} finally {
if (output) {
output.end()
}
}
async delete(path, options) {
const {ref} = options
this.out(JSON.stringify({
path: path.split('/'),
commit: await this.repo.saveEntry(ref, parse(path, null, options), options),
}))
return 1

@@ -18,0 +13,0 @@ }

@@ -1,31 +0,22 @@

const {createWriteStream} = require('fs')
const GitCommand = require('../../git-command')
const {MemRepo, FsRepo} = require('../../repo')
const GitOutCommand = require('../../git-out-command')
const {parse} = require('../../entry')
class DeleteTextCommand extends GitCommand {
async delete(repo, source, path, options) {
const {ref, output} = options
try {
const out = output ? message => output.write(`${message}\n`) : this.log
await this.mount(repo, source, options)
const hash = await repo.saveEntry(ref, parse(path, null, options), options)
out(`${hash} ${path}`)
} finally {
if (output) {
output.end()
}
}
class DeleteTextCommand extends GitOutCommand {
async delete(path, options) {
const {ref} = options
const hash = await this.repo.saveEntry(ref, parse(path, null, options), options)
this.out(`${hash} ${path}`)
return 1
}
async init() {
await super.init()
const {args: {output}} = this
this.out = output ? message => output.write(`${message}\n`) : this.log
}
async run() {
const {args, flags} = this.parse(DeleteTextCommand)
const {source, output, path} = args
try {
const count = await this.delete(source.protocol ? new MemRepo() : new FsRepo(source.path), source, path, {output, ...flags})
this.log(`Deleted ${count} ${count === 1 ? 'entry' : 'entries'}`)
} catch (error) {
this.error(error.message, {exit: 1})
}
const {args: {path}, flags: options} = this
const count = await this.delete(path, options)
this.log(`Deleted ${count} ${count === 1 ? 'entry' : 'entries'}`)
}

@@ -36,3 +27,3 @@ }

DeleteTextCommand.args = [
...GitCommand.args,
...GitOutCommand.args.slice(0, -1),
{

@@ -43,11 +34,7 @@ name: 'path',

},
{
name: 'output',
description: 'output file path',
parse: input => createWriteStream(input),
},
...GitOutCommand.args.slice(-1),
]
DeleteTextCommand.flags = GitCommand.flags
DeleteTextCommand.flags = GitOutCommand.flags
DeleteTextCommand.aliases = ['rm', 'del', 'rm:text', 'del:text']
module.exports = DeleteTextCommand
const ListTextCommand = require('./text')
class ListJsonCommand extends ListTextCommand {
async list(repo, source, options) {
const {output} = options
async list(options) {
let count = 0
try {
const out = output ? message => output.write(`${message}\n`) : this.log
await this.mount(repo, source, options)
for await (const file of repo.listEntries(await this.tree(repo, options), options)) {
out(JSON.stringify(file))
count++
}
} finally {
if (output) {
output.end()
}
for await (const file of this.repo.listEntries(await this.tree(options), options)) {
this.out(JSON.stringify(file))
count++
}

@@ -19,0 +10,0 @@ return count

@@ -1,20 +0,9 @@

const {createWriteStream} = require('fs')
const GitCommand = require('../../git-command')
const {MemRepo, FsRepo} = require('../../repo')
const GitOutCommand = require('../../git-out-command')
class ListTextCommand extends GitCommand {
async list(repo, source, options) {
const {output} = options
class ListTextCommand extends GitOutCommand {
async list(options) {
let count = 0
try {
const out = output ? message => output.write(`${message}\n`) : this.log
await this.mount(repo, source, options)
for await (const file of repo.listEntries(await this.tree(repo, options), options)) {
out(`${file.hash} ${file.path.join('/')}`)
count++
}
} finally {
if (output) {
output.end()
}
for await (const file of this.repo.listEntries(await this.tree(options), options)) {
this.out(`${file.hash} ${file.path.join('/')}`)
count++
}

@@ -24,11 +13,12 @@ return count

async init() {
await super.init()
const {args: {output}} = this
this.out = output ? message => output.write(`${message}\n`) : this.log
}
async run() {
const {args, flags} = this.parse(ListTextCommand)
const {source, output} = args
try {
const count = await this.list(source.protocol ? new MemRepo() : new FsRepo(source.path), source, {output, ...flags})
this.log(`${output ? 'Wrote' : 'Listed'} ${count} ${count === 1 ? 'entry' : 'entries'}`)
} catch (error) {
this.error(error.message, {exit: 1})
}
const {args: {output}, flags: options} = this
const count = await this.list(options)
this.log(`${output ? 'Wrote' : 'Listed'} ${count} ${count === 1 ? 'entry' : 'entries'}`)
}

@@ -38,13 +28,6 @@ }

ListTextCommand.description = 'lists entries in text format from a BlockFor.fun git registry'
ListTextCommand.args = [
...GitCommand.args,
{
name: 'output',
description: 'output file path',
parse: input => createWriteStream(input),
},
]
ListTextCommand.flags = GitCommand.flags
ListTextCommand.args = GitOutCommand.args
ListTextCommand.flags = GitOutCommand.flags
ListTextCommand.aliases = ['ls', 'ls:text']
module.exports = ListTextCommand
const ReadTextCommand = require('./text')
class ReadJsonCommand extends ReadTextCommand {
async read(repo, source, path, options) {
const {output} = options
try {
const out = output ? message => output.write(message) : this.log
await this.mount(repo, source, options)
out(JSON.stringify(await repo.loadEntry(await this.tree(repo, options), path, options)))
} finally {
if (output) {
output.end()
}
}
async read(path, options) {
this.out(JSON.stringify(await this.repo.loadEntry(await this.tree(options), path, options)))
return 1

@@ -16,0 +7,0 @@ }

@@ -1,30 +0,20 @@

const {createWriteStream} = require('fs')
const GitCommand = require('../../git-command')
const {MemRepo, FsRepo} = require('../../repo')
const GitOutCommand = require('../../git-out-command')
const {compile} = require('../../entry')
class ReadTextCommand extends GitCommand {
async read(repo, source, path, options) {
const {output} = options
try {
const out = output ? message => output.write(message) : this.log
await this.mount(repo, source, options)
out(compile(await repo.loadEntry(await this.tree(repo, options), path, options), options).body)
} finally {
if (output) {
output.end()
}
}
class ReadTextCommand extends GitOutCommand {
async read(path, options) {
this.out(compile(await this.repo.loadEntry(await this.tree(options), path, options), options).body)
return 1
}
async init() {
await super.init()
const {args: {output}} = this
this.out = output ? message => output.write(message) : this.log
}
async run() {
const {args, flags} = this.parse(ReadTextCommand)
const {source, path, output} = args
try {
const count = await this.read(source.protocol ? new MemRepo() : new FsRepo(source.path), source, path, {output, ...flags})
this.log(`${output ? 'Wrote' : 'Read'} ${count} ${count === 1 ? 'entry' : 'entries'}`)
} catch (error) {
this.error(error.message, {exit: 1})
}
const {args: {path, output}, flags: options} = this
const count = await this.read(path, options)
this.log(`${output ? 'Wrote' : 'Read'} ${count} ${count === 1 ? 'entry' : 'entries'}`)
}

@@ -35,3 +25,3 @@ }

ReadTextCommand.args = [
...GitCommand.args,
...GitOutCommand.args.slice(0, -1),
{

@@ -42,11 +32,7 @@ name: 'path',

},
{
name: 'output',
description: 'output file path',
parse: input => createWriteStream(input),
},
...GitOutCommand.args.slice(-1),
]
ReadTextCommand.flags = GitCommand.flags
ReadTextCommand.flags = GitOutCommand.flags
ReadTextCommand.aliases = ['get', 'get:text']
module.exports = ReadTextCommand

@@ -1,2 +0,1 @@

const toString = require('stream-to-string')
const WriteTextCommand = require('./text')

@@ -6,10 +5,10 @@ const {parse} = require('../../entry')

class WriteJsonCommand extends WriteTextCommand {
async write(repo, source, path, options) {
const {ref, input} = options
try {
await this.mount(repo, source, options)
this.log(await repo.saveEntry(ref, {...JSON.parse(await toString(input)), ...parse(path, null, options)}))
} finally {
input.destroy()
}
async write(path, body, options) {
const {ref} = options
const entry = {...JSON.parse(body), ...parse(path, null, options)}
this.log(JSON.stringify({
path: path.split('/'),
commit: await this.repo.saveEntry(ref, entry),
entry,
}))
return 1

@@ -16,0 +15,0 @@ }

const {createReadStream} = require('fs')
const toString = require('stream-to-string')
const GitCommand = require('../../git-command')
const {MemRepo, FsRepo} = require('../../repo')
const {parse} = require('../../entry')
class WriteTextCommand extends GitCommand {
async write(repo, source, path, options) {
const {ref, input} = options
try {
await this.mount(repo, source, options)
const commit = await repo.saveEntry(ref, parse(path, await toString(input), options))
this.log(`Committed ${commit}`)
} finally {
async write(path, body, options) {
const {ref} = options
const hash = await this.repo.saveEntry(ref, parse(path, body, options))
this.log(`${hash} ${path}`)
return 1
}
async finally(err) {
const {args: {input}} = this
if (input) {
input.destroy()
}
return 1
return super.finally(err)
}
async run() {
const {args, flags} = this.parse(WriteTextCommand)
const {source, path, input} = args
try {
const count = await this.write(source.protocol ? new MemRepo() : new FsRepo(source.path), source, path, {input, ...flags})
this.log(`Wrote ${count} ${count === 1 ? 'entry' : 'entries'}`)
} catch (error) {
this.error(error.message, {exit: 1})
}
const {args: {path, input}, flags: options} = this
const count = await this.write(path, await toString(input), options)
this.log(`Wrote ${count} ${count === 1 ? 'entry' : 'entries'}`)
}

@@ -30,0 +27,0 @@ }

const {parse} = require('url')
const {Command, flags} = require('@oclif/command')
const {MemRepo, FsRepo} = require('./repo')
class GitCommand extends Command {
async mount(repo, url, options) {
async init() {
await super.init()
const {args, flags} = this.parse(this.constructor)
const {source} = args
this.args = args
this.flags = flags
this.repo = source.protocol ? new MemRepo() : new FsRepo(source.path)
await this.mount(source, flags)
}
async catch(err) {
this.error(err.message, {exit: 1})
return super.catch(err)
}
async mount(url, options) {
const {fetch = url.href, spec} = options

@@ -10,7 +26,8 @@ this.log(`Mounting ${url.protocol ? 'mem' : 'fs'} repo from ${url.href}`)

this.log(`Fetching ${spec} from ${fetch}`)
await repo.fetch(fetch, spec, {progress: p => process.stdout.write(p)})
await this.repo.fetch(fetch, spec, {progress: p => process.stdout.write(p)})
}
}
async tree(repo, options) {
async tree(options) {
const {repo} = this
const {ref} = options

@@ -17,0 +34,0 @@ this.log(`Resolving ${ref}`)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc