Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ink

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ink - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

20

index.js

@@ -94,2 +94,19 @@ 'use strict';

const consoleMethods = ['dir', 'log', 'info', 'warn', 'error'];
consoleMethods.forEach(method => {
const originalFn = console[method];
console[method] = (...args) => {
log.clear();
log.done();
originalFn.apply(console, args);
update();
};
console[method].restore = () => {
console[method] = originalFn;
};
});
const exit = () => {

@@ -102,2 +119,3 @@ if (isUnmounted) {

stdin.removeListener('keypress', onKeyPress);
stdin.pause();

@@ -107,2 +125,4 @@ isUnmounted = true;

log.done();
consoleMethods.forEach(method => console[method].restore());
};

@@ -109,0 +129,0 @@

10

lib/components/group.js
'use strict';
module.exports = ({children}) => children;
const PropTypes = require('prop-types');
const Group = ({children}) => children;
Group.propTypes = {
children: PropTypes.node
};
module.exports = Group;
'use strict';
const PropTypes = require('prop-types');
const arrify = require('arrify');

@@ -68,5 +69,18 @@ const Newline = require('./components/newline');

checkPropTypes(props) {
const component = this.component;
if (process.env.NODE_ENV !== 'production' && typeof component.propTypes === 'object') {
const name = component.displayName || component.name;
PropTypes.checkPropTypes(component.propTypes, props, 'prop', name);
}
}
mount() {
const props = Object.assign({}, this.component.defaultProps, this.props);
this.checkPropTypes(props);
if (this.isClassComponent) {
const instance = new this.component(this.props, this.context); // eslint-disable-line new-cap
const instance = new this.component(props, this.context); // eslint-disable-line new-cap
instance._onUpdate = this.onUpdate;

@@ -79,3 +93,3 @@ Object.assign(this.context, instance.getChildContext());

} else {
this.children = this.component(this.props, this.context);
this.children = this.component(props, this.context);
}

@@ -133,5 +147,8 @@

rerender() {
const nextProps = Object.assign({}, this.component.defaultProps, this.props);
this.checkPropTypes(nextProps);
if (this.isClassComponent) {
this.instance.componentWillUpdate(this.props, this.nextState);
this.instance.props = this.props;
this.instance.componentWillUpdate(nextProps, this.nextState);
this.instance.props = nextProps;
this.instance.state = this.nextState;

@@ -145,3 +162,3 @@ this.instance._pendingState = null;

this.children = arrify(this.component(this.props, this.context));
this.children = arrify(this.component(nextProps, this.context));
}

@@ -148,0 +165,0 @@

'use strict';
const PropTypes = require('prop-types');
const Component = require('./component');

@@ -11,2 +12,6 @@

StringComponent.propTypes = {
children: PropTypes.node // eslint-disable-line react/require-default-props
};
module.exports = StringComponent;

@@ -17,2 +17,6 @@ 'use strict';

if (process.env.NODE_ENV !== 'production') {
VNode.prototype.$$typeof = Symbol.for('react.element');
}
module.exports = VNode;

18

package.json
{
"name": "ink",
"version": "0.2.0",
"version": "0.2.1",
"description": "React for CLI",

@@ -42,3 +42,4 @@ "license": "MIT",

"lodash.isequal": "^4.5.0",
"log-update": "^1.0.2"
"log-update": "^1.0.2",
"prop-types": "^15.5.10"
},

@@ -77,5 +78,2 @@ "devDependencies": {

],
"rules": {
"react/prop-types": 0
},
"settings": {

@@ -85,4 +83,12 @@ "react": {

}
}
},
"overrides": [
{
"files": "test/*.js",
"rules": {
"react/prop-types": 0
}
}
]
}
}

@@ -216,2 +216,30 @@ <h1 align="center">

To set default props on specific component, use `defaultProps`:
```js
const Test = ({first, second}) => `${first} ${second}`;
Test.defaultProps = {
first: 'Hello',
second: 'World'
};
// <Test/> => "Hello World"
```
##### Prop Types
Ink supports prop types out-of-the-box. All you have to do is set them in the same way you would in React:
```js
const PropTypes = require('prop-types');
Test.propTypes = {
first: PropTypes.string.isRequired,
second: PropTypes.string
};
```
**Note**: Prop types are only checked when `NODE_ENV` isn't `'production'`.
#### Lifecycle Methods

@@ -218,0 +246,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc