1
- import { promises as fsp } from 'fs ' ;
2
- import path from 'path' ;
1
+ import fs from 'node:fs/promises ' ;
2
+ import path from 'node: path' ;
3
3
4
4
const pluginName = process . argv . slice ( 2 ) . join ( ' ' ) ;
5
5
@@ -33,16 +33,16 @@ console.log(`- Creating new plugin ${pluginName}`);
33
33
34
34
// Copy base plugin
35
35
{
36
- await fsp . rm ( pluginDir , { recursive : true , force : true } ) ;
37
- await fsp . cp ( basePluginDir , pluginDir , { recursive : true } ) ;
36
+ await fs . rm ( pluginDir , { recursive : true , force : true } ) ;
37
+ await fs . cp ( basePluginDir , pluginDir , { recursive : true } ) ;
38
38
39
39
console . log ( '- Copied base plugin to' , pluginDir ) ;
40
40
}
41
41
42
42
// Remove unnecessary files
43
43
{
44
- await fsp . rm ( path . join ( pluginDir , 'dist' ) , { recursive : true , force : true } ) ;
45
- await fsp . rm ( path . join ( pluginDir , 'node_modules' ) , { recursive : true , force : true } ) ;
44
+ await fs . rm ( path . join ( pluginDir , 'dist' ) , { recursive : true , force : true } ) ;
45
+ await fs . rm ( path . join ( pluginDir , 'node_modules' ) , { recursive : true , force : true } ) ;
46
46
47
47
console . log ( '- Cleaned up files and directories not required in a new plugin' ) ;
48
48
}
@@ -55,7 +55,7 @@ console.log(`- Creating new plugin ${pluginName}`);
55
55
await replaceBasePluginReferencesForFilePath ( path . join ( pluginDir , 'test' , '_tape.mjs' ) ) ;
56
56
await replaceBasePluginReferencesForFilePath ( path . join ( pluginDir , 'README.md' ) ) ;
57
57
await replaceBasePluginReferencesForFilePath ( path . join ( pluginDir , 'INSTALL.md' ) ) ;
58
- await fsp . writeFile (
58
+ await fs . writeFile (
59
59
path . join ( pluginDir , 'CHANGELOG.md' ) ,
60
60
`# Changes to PostCSS ${ pluginName }
61
61
@@ -70,7 +70,7 @@ console.log(`- Creating new plugin ${pluginName}`);
70
70
71
71
// Update package.json
72
72
{
73
- const packageInfo = JSON . parse ( await fsp . readFile ( path . join ( pluginDir , 'package.json' ) , 'utf8' ) ) ;
73
+ const packageInfo = JSON . parse ( await fs . readFile ( path . join ( pluginDir , 'package.json' ) , 'utf8' ) ) ;
74
74
packageInfo . name = packageName ;
75
75
packageInfo . description = `TODO: Add description for ${ pluginName } ` ;
76
76
packageInfo . version = '0.0.0' ;
@@ -83,7 +83,7 @@ console.log(`- Creating new plugin ${pluginName}`);
83
83
84
84
packageInfo . repository . directory = `plugins/${ pluginSlug } ` ;
85
85
86
- await fsp . writeFile ( path . join ( pluginDir , 'package.json' ) , JSON . stringify ( packageInfo , null , '\t' ) ) ;
86
+ await fs . writeFile ( path . join ( pluginDir , 'package.json' ) , JSON . stringify ( packageInfo , null , '\t' ) ) ;
87
87
88
88
console . log ( '- Updated "package.json"' ) ;
89
89
}
@@ -104,10 +104,10 @@ console.log('\nDone! 🎉');
104
104
105
105
// Helpers
106
106
async function replaceBasePluginReferencesForFilePath ( filePath ) {
107
- await fsp . writeFile (
107
+ await fs . writeFile (
108
108
filePath ,
109
109
replaceBasePluginReferences (
110
- ( await fsp . readFile ( filePath , 'utf8' ) ) . toString ( ) ,
110
+ ( await fs . readFile ( filePath , 'utf8' ) ) . toString ( ) ,
111
111
) ,
112
112
) ;
113
113
}
0 commit comments