-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Example fs-extra #100
Example fs-extra #100
Changes from 2 commits
d659010
7eccdd1
8e473ef
960e95b
7949c70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
'use strict'; | ||
|
||
const mkdirp = require('mkdirp'); | ||
const rm = require('rimraf'); | ||
const { join } = require('path'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L'intention initiale c'est de copier le répertoire contenant le script |
||
const fs = require('fs-extra'); | ||
|
||
fs.copy(__dirname, '/tmp/nodebook-examples', (err) => { | ||
const dirpath = join(__dirname, '..', '..', 'tmp', 'nodebook-examples'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Du coup cette ligne change l'emplacement de copie. Ce qui est un plus je pense car On est bien d'accord que tu veux copier vers la racine du repo ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oui, j'ai gardé la même logique que le script |
||
|
||
fs.ensureDir(dirpath, function (err) { | ||
if (err) { | ||
return console.error('Une erreur s\'est produite.', err); | ||
fs.mkdirp(dirpath); | ||
console.log('Dossier crée :', dirpath); | ||
} | ||
}) | ||
|
||
rm(dirpath, () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Top, je vais refactoriser ça. |
||
fs.copy(__dirname, dirpath, (err) => { | ||
if (err) { | ||
return console.error('Une erreur s\'est produite.', err); | ||
} | ||
else { | ||
return console.log('Dossier copié : ', dirpath); | ||
} | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vu que tu
utilises fs.mkdirp
, cette dépendance n'est plus nécessaire.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh merci, un bel exemple de cargo culte 😉