Last active
December 11, 2015 09:09
-
-
Save skyend/4578431 to your computer and use it in GitHub Desktop.
Node.js Module creator 생성자를 포함하는 형식의 모듈 템플릿을 생성하는 스크립트
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use 5.010; | |
# Use | |
# ./create_module.pl ./lib/Model/A | |
if ( $ARGV[0] =~ /^(\.?)((?:\/\w+)*)\/(\w+)$/ ) | |
{ | |
my $filename = "$1$2/$3.js"; | |
say "try to create $filename"; | |
unless( -e $filename ){ | |
open my $newfile , '>', $filename or die('Permission error'); | |
my $tem_text = <<TEM | |
/* | |
Module : $3 | |
Overview | |
some text.. | |
Exports -> | |
global.exports.somefunc = function(){}; | |
*/ | |
// Extract Modules | |
// Global | |
global.exports = {}; // Public Object | |
/** | |
* Constructor | |
**/ | |
var $3 = function(){ | |
return global.exports; | |
} | |
module.exports = $3; | |
TEM | |
; | |
print $newfile $tem_text or die ('Can\' Write'); | |
say "create $filename"; | |
close $newfile; | |
}else{ | |
say "파일이 이미 존재 합니다."; | |
} | |
} else { | |
say "위치지정이 잘못 되었습니다."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment