Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use command replace io #23

Merged
merged 3 commits into from
May 9, 2022
Merged

feat: use command replace io #23

merged 3 commits into from
May 9, 2022

Conversation

nonzzz
Copy link
Collaborator

@nonzzz nonzzz commented May 9, 2022

Background

Description

  • ReWrite WriteNpm func.

Others

@nonzzz nonzzz requested a review from zaunist May 9, 2022 04:54
@nonzzz
Copy link
Collaborator Author

nonzzz commented May 9, 2022

@zaunist cc.

@codecov-commenter
Copy link

codecov-commenter commented May 9, 2022

Codecov Report

Merging #23 (6db6dc3) into master (7523ace) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #23   +/-   ##
=======================================
  Coverage   75.00%   75.00%           
=======================================
  Files           2        2           
  Lines          20       20           
=======================================
  Hits           15       15           
  Misses          4        4           
  Partials        1        1           
Flag Coverage Δ
unittests 75.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@nonzzz
Copy link
Collaborator Author

nonzzz commented May 9, 2022

You can view npm config docs. Can found npm config set registry uri. So i think we can use npm command replace past io operate. From my point, We use npm command can reduce unnecessary code of grm. And get more friendly err log from npm self. If user set a err uri.

Comment on lines 62 to 65
flag, err := registry.WriteNpm(uri)
if flag {
logger.Success(internal.StringJoin("[Grm]: use", name, "success~", registry.Eol()))
return 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use if err != nil ? Even though this style is silly, we should use a uniform style for our code. The use of if flag here also causes the call to writeNpm to return 0 and return 1 in a different style.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. May we can discuss how to unify the norms.Because in project. we have process state code. In my mind. Just like process state code we can provide a enum,
It look like

eg:

const (

NORMAL = 1 << iota
ABORT
)

And for other err. May if err !=nil. My mind don't have an answer for now :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me.

nonzzz and others added 2 commits May 9, 2022 14:30
Co-authored-by: 失眠是真滴难受 <imbozhong@gmail.com>
@nonzzz
Copy link
Collaborator Author

nonzzz commented May 9, 2022

I push new code. This commit I just kept the err return at write_ini.go file.

@nonzzz
Copy link
Collaborator Author

nonzzz commented May 9, 2022

@zaunist cc

Copy link
Member

@zaunist zaunist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zaunist zaunist merged commit 8e06fb8 into modern-magic:master May 9, 2022
@nonzzz nonzzz deleted the feat/writeNpm branch May 9, 2022 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants